Fossil SCM

Add software version information and database stats to the /stat page.

drh 2010-07-06 21:22 trunk
Commit 5acf617104131086d9120b8943dff1f5cdec64dd
3 files changed +2 +1 +24 -5
+2
--- src/db.c
+++ src/db.c
@@ -610,16 +610,18 @@
610610
** already open, then attach zDbName using the name zLabel.
611611
*/
612612
void db_open_or_attach(const char *zDbName, const char *zLabel){
613613
if( !g.db ){
614614
g.db = openDatabase(zDbName);
615
+ g.zRepoDb = "main";
615616
db_connection_init();
616617
}else{
617618
#ifdef __MINGW32__
618619
zDbName = sqlite3_win32_mbcs_to_utf8(zDbName);
619620
#endif
620621
db_multi_exec("ATTACH DATABASE %Q AS %s", zDbName, zLabel);
622
+ g.zRepoDb = mprintf("%s", zLabel);
621623
}
622624
}
623625
624626
/*
625627
** Open the user database in "~/.fossil". Create the database anew if
626628
--- src/db.c
+++ src/db.c
@@ -610,16 +610,18 @@
610 ** already open, then attach zDbName using the name zLabel.
611 */
612 void db_open_or_attach(const char *zDbName, const char *zLabel){
613 if( !g.db ){
614 g.db = openDatabase(zDbName);
 
615 db_connection_init();
616 }else{
617 #ifdef __MINGW32__
618 zDbName = sqlite3_win32_mbcs_to_utf8(zDbName);
619 #endif
620 db_multi_exec("ATTACH DATABASE %Q AS %s", zDbName, zLabel);
 
621 }
622 }
623
624 /*
625 ** Open the user database in "~/.fossil". Create the database anew if
626
--- src/db.c
+++ src/db.c
@@ -610,16 +610,18 @@
610 ** already open, then attach zDbName using the name zLabel.
611 */
612 void db_open_or_attach(const char *zDbName, const char *zLabel){
613 if( !g.db ){
614 g.db = openDatabase(zDbName);
615 g.zRepoDb = "main";
616 db_connection_init();
617 }else{
618 #ifdef __MINGW32__
619 zDbName = sqlite3_win32_mbcs_to_utf8(zDbName);
620 #endif
621 db_multi_exec("ATTACH DATABASE %Q AS %s", zDbName, zLabel);
622 g.zRepoDb = mprintf("%s", zLabel);
623 }
624 }
625
626 /*
627 ** Open the user database in "~/.fossil". Create the database anew if
628
+1
--- src/main.c
+++ src/main.c
@@ -55,10 +55,11 @@
5555
int useAttach; /* True if global_config is attached to repository */
5656
int configOpen; /* True if the config database is open */
5757
long long int now; /* Seconds since 1970 */
5858
int repositoryOpen; /* True if the main repository database is open */
5959
char *zRepositoryName; /* Name of the repository database */
60
+ char *zRepoDb; /* SQLite database name for the repository */
6061
const char *zHome; /* Name of user home directory */
6162
int localOpen; /* True if the local database is open */
6263
char *zLocalRoot; /* The directory holding the local database */
6364
int minPrefix; /* Number of digits needed for a distinct UUID */
6465
int fSqlTrace; /* True if -sqltrace flag is present */
6566
--- src/main.c
+++ src/main.c
@@ -55,10 +55,11 @@
55 int useAttach; /* True if global_config is attached to repository */
56 int configOpen; /* True if the config database is open */
57 long long int now; /* Seconds since 1970 */
58 int repositoryOpen; /* True if the main repository database is open */
59 char *zRepositoryName; /* Name of the repository database */
 
60 const char *zHome; /* Name of user home directory */
61 int localOpen; /* True if the local database is open */
62 char *zLocalRoot; /* The directory holding the local database */
63 int minPrefix; /* Number of digits needed for a distinct UUID */
64 int fSqlTrace; /* True if -sqltrace flag is present */
65
--- src/main.c
+++ src/main.c
@@ -55,10 +55,11 @@
55 int useAttach; /* True if global_config is attached to repository */
56 int configOpen; /* True if the config database is open */
57 long long int now; /* Seconds since 1970 */
58 int repositoryOpen; /* True if the main repository database is open */
59 char *zRepositoryName; /* Name of the repository database */
60 char *zRepoDb; /* SQLite database name for the repository */
61 const char *zHome; /* Name of user home directory */
62 int localOpen; /* True if the local database is open */
63 char *zLocalRoot; /* The directory holding the local database */
64 int minPrefix; /* Number of digits needed for a distinct UUID */
65 int fSqlTrace; /* True if -sqltrace flag is present */
66
+24 -5
--- src/stat.c
+++ src/stat.c
@@ -61,33 +61,52 @@
6161
a = t/fsize;
6262
@ %d(a):%d(b)
6363
@ </td></tr>
6464
}
6565
@ <tr><th>Number&nbsp;Of&nbsp;Check-ins:</th><td>
66
- n = db_int(0, "SELECT count(distinct mid) FROM mlink");
66
+ n = db_int(0, "SELECT count(distinct mid) FROM mlink /*scan*/");
6767
@ %d(n)
6868
@ </td></tr>
6969
@ <tr><th>Number&nbsp;Of&nbsp;Files:</th><td>
70
- n = db_int(0, "SELECT count(*) FROM filename");
70
+ n = db_int(0, "SELECT count(*) FROM filename /*scan*/");
7171
@ %d(n)
7272
@ </td></tr>
7373
@ <tr><th>Number&nbsp;Of&nbsp;Wiki&nbsp;Pages:</th><td>
74
- n = db_int(0, "SELECT count(*) FROM tag WHERE +tagname GLOB 'wiki-*'");
74
+ n = db_int(0, "SELECT count(*) FROM tag /*scan*/"
75
+ " WHERE +tagname GLOB 'wiki-*'");
7576
@ %d(n)
7677
@ </td></tr>
7778
@ <tr><th>Number&nbsp;Of&nbsp;Tickets:</th><td>
78
- n = db_int(0, "SELECT count(*) FROM tag WHERE +tagname GLOB 'tkt-*'");
79
+ n = db_int(0, "SELECT count(*) FROM tag /*scan*/"
80
+ " WHERE +tagname GLOB 'tkt-*'");
7981
@ %d(n)
8082
@ </td></tr>
8183
@ <tr><th>Duration&nbsp;Of&nbsp;Project:</th><td>
82
- n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event) + 0.99");
84
+ n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
85
+ " + 0.99");
8386
@ %d(n) days
8487
@ </td></tr>
8588
@ <tr><th>Project&nbsp;ID:</th><td>
8689
@ %h(db_get("project-code",""))
8790
@ </td></tr>
8891
@ <tr><th>Server&nbsp;ID:</th><td>
8992
@ %h(db_get("server-code",""))
9093
@ </td></tr>
94
+
95
+ @ <tr><th>Fossil&nbsp;Version:</th><td>
96
+ @ %h(MANIFEST_DATE) %h(MANIFEST_VERSION)
97
+ @ </td></tr>
98
+ @ <tr><th>SQLite&nbsp;Version:</th><td>
99
+ @ %h(db_text(0, "SELECT substr(sqlite_source_id(),1,30)"))
100
+ @ (%h(SQLITE_VERSION))
101
+ @ </td></tr>
102
+ @ <tr><th>Database&nbsp;Stats:</th><td>
103
+ @ %d(db_int(0, "PRAGMA %s.page_count", g.zRepoDb)) pages,
104
+ @ %d(db_int(0, "PRAGMA %s.page_size", g.zRepoDb)) bytes/page,
105
+ @ %d(db_int(0, "PRAGMA %s.freelist_count", g.zRepoDb)) free pages,
106
+ @ %s(db_text(0, "PRAGMA %s.encoding", g.zRepoDb)),
107
+ @ %s(db_text(0, "PRAGMA %s.journal_mode", g.zRepoDb)) mode
108
+ @ </td></tr>
109
+
91110
@ </table></p>
92111
style_footer();
93112
}
94113
--- src/stat.c
+++ src/stat.c
@@ -61,33 +61,52 @@
61 a = t/fsize;
62 @ %d(a):%d(b)
63 @ </td></tr>
64 }
65 @ <tr><th>Number&nbsp;Of&nbsp;Check-ins:</th><td>
66 n = db_int(0, "SELECT count(distinct mid) FROM mlink");
67 @ %d(n)
68 @ </td></tr>
69 @ <tr><th>Number&nbsp;Of&nbsp;Files:</th><td>
70 n = db_int(0, "SELECT count(*) FROM filename");
71 @ %d(n)
72 @ </td></tr>
73 @ <tr><th>Number&nbsp;Of&nbsp;Wiki&nbsp;Pages:</th><td>
74 n = db_int(0, "SELECT count(*) FROM tag WHERE +tagname GLOB 'wiki-*'");
 
75 @ %d(n)
76 @ </td></tr>
77 @ <tr><th>Number&nbsp;Of&nbsp;Tickets:</th><td>
78 n = db_int(0, "SELECT count(*) FROM tag WHERE +tagname GLOB 'tkt-*'");
 
79 @ %d(n)
80 @ </td></tr>
81 @ <tr><th>Duration&nbsp;Of&nbsp;Project:</th><td>
82 n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event) + 0.99");
 
83 @ %d(n) days
84 @ </td></tr>
85 @ <tr><th>Project&nbsp;ID:</th><td>
86 @ %h(db_get("project-code",""))
87 @ </td></tr>
88 @ <tr><th>Server&nbsp;ID:</th><td>
89 @ %h(db_get("server-code",""))
90 @ </td></tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91 @ </table></p>
92 style_footer();
93 }
94
--- src/stat.c
+++ src/stat.c
@@ -61,33 +61,52 @@
61 a = t/fsize;
62 @ %d(a):%d(b)
63 @ </td></tr>
64 }
65 @ <tr><th>Number&nbsp;Of&nbsp;Check-ins:</th><td>
66 n = db_int(0, "SELECT count(distinct mid) FROM mlink /*scan*/");
67 @ %d(n)
68 @ </td></tr>
69 @ <tr><th>Number&nbsp;Of&nbsp;Files:</th><td>
70 n = db_int(0, "SELECT count(*) FROM filename /*scan*/");
71 @ %d(n)
72 @ </td></tr>
73 @ <tr><th>Number&nbsp;Of&nbsp;Wiki&nbsp;Pages:</th><td>
74 n = db_int(0, "SELECT count(*) FROM tag /*scan*/"
75 " WHERE +tagname GLOB 'wiki-*'");
76 @ %d(n)
77 @ </td></tr>
78 @ <tr><th>Number&nbsp;Of&nbsp;Tickets:</th><td>
79 n = db_int(0, "SELECT count(*) FROM tag /*scan*/"
80 " WHERE +tagname GLOB 'tkt-*'");
81 @ %d(n)
82 @ </td></tr>
83 @ <tr><th>Duration&nbsp;Of&nbsp;Project:</th><td>
84 n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
85 " + 0.99");
86 @ %d(n) days
87 @ </td></tr>
88 @ <tr><th>Project&nbsp;ID:</th><td>
89 @ %h(db_get("project-code",""))
90 @ </td></tr>
91 @ <tr><th>Server&nbsp;ID:</th><td>
92 @ %h(db_get("server-code",""))
93 @ </td></tr>
94
95 @ <tr><th>Fossil&nbsp;Version:</th><td>
96 @ %h(MANIFEST_DATE) %h(MANIFEST_VERSION)
97 @ </td></tr>
98 @ <tr><th>SQLite&nbsp;Version:</th><td>
99 @ %h(db_text(0, "SELECT substr(sqlite_source_id(),1,30)"))
100 @ (%h(SQLITE_VERSION))
101 @ </td></tr>
102 @ <tr><th>Database&nbsp;Stats:</th><td>
103 @ %d(db_int(0, "PRAGMA %s.page_count", g.zRepoDb)) pages,
104 @ %d(db_int(0, "PRAGMA %s.page_size", g.zRepoDb)) bytes/page,
105 @ %d(db_int(0, "PRAGMA %s.freelist_count", g.zRepoDb)) free pages,
106 @ %s(db_text(0, "PRAGMA %s.encoding", g.zRepoDb)),
107 @ %s(db_text(0, "PRAGMA %s.journal_mode", g.zRepoDb)) mode
108 @ </td></tr>
109
110 @ </table></p>
111 style_footer();
112 }
113

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button