Fossil SCM

Keep track of when the repository was last rebuilt and display it on the stats page.

mistachkin 2013-11-11 22:41 trunk
Commit c0242ad4d8d240caa20e803f90bd82719913f438
--- src/clone.c
+++ src/clone.c
@@ -156,10 +156,11 @@
156156
db_record_repository_filename(g.argv[3]);
157157
db_initial_setup(0, 0, zDefaultUser, 0);
158158
user_select();
159159
db_set("content-schema", CONTENT_SCHEMA, 0);
160160
db_set("aux-schema", AUX_SCHEMA, 0);
161
+ db_set("rebuilt", get_version(), 0);
161162
url_remember();
162163
if( g.zSSLIdentity!=0 ){
163164
/* If the --ssl-identity option was specified, store it as a setting */
164165
Blob fn;
165166
blob_zero(&fn);
166167
--- src/clone.c
+++ src/clone.c
@@ -156,10 +156,11 @@
156 db_record_repository_filename(g.argv[3]);
157 db_initial_setup(0, 0, zDefaultUser, 0);
158 user_select();
159 db_set("content-schema", CONTENT_SCHEMA, 0);
160 db_set("aux-schema", AUX_SCHEMA, 0);
 
161 url_remember();
162 if( g.zSSLIdentity!=0 ){
163 /* If the --ssl-identity option was specified, store it as a setting */
164 Blob fn;
165 blob_zero(&fn);
166
--- src/clone.c
+++ src/clone.c
@@ -156,10 +156,11 @@
156 db_record_repository_filename(g.argv[3]);
157 db_initial_setup(0, 0, zDefaultUser, 0);
158 user_select();
159 db_set("content-schema", CONTENT_SCHEMA, 0);
160 db_set("aux-schema", AUX_SCHEMA, 0);
161 db_set("rebuilt", get_version(), 0);
162 url_remember();
163 if( g.zSSLIdentity!=0 ){
164 /* If the --ssl-identity option was specified, store it as a setting */
165 Blob fn;
166 blob_zero(&fn);
167
+18
--- src/db.c
+++ src/db.c
@@ -1340,10 +1340,11 @@
13401340
Blob hash;
13411341
Blob manifest;
13421342
13431343
db_set("content-schema", CONTENT_SCHEMA, 0);
13441344
db_set("aux-schema", AUX_SCHEMA, 0);
1345
+ db_set("rebuilt", get_version(), 0);
13451346
if( makeServerCodes ){
13461347
db_multi_exec(
13471348
"INSERT INTO config(name,value,mtime)"
13481349
" VALUES('server-code', lower(hex(randomblob(20))),now());"
13491350
"INSERT INTO config(name,value,mtime)"
@@ -1798,10 +1799,27 @@
17981799
}
17991800
if( z==0 ){
18001801
z = zDefault;
18011802
}
18021803
return z;
1804
+}
1805
+char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){
1806
+ char *z = 0;
1807
+ if( g.repositoryOpen ){
1808
+ z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
1809
+ }
1810
+ if( z==0 && g.zConfigDbName ){
1811
+ db_swap_connections();
1812
+ z = db_text(0, "SELECT mtime FROM global_config WHERE name=%Q", zName);
1813
+ db_swap_connections();
1814
+ }
1815
+ if( z==0 ){
1816
+ z = zDefault;
1817
+ }else if( zFormat!=0 ){
1818
+ z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z);
1819
+ }
1820
+ return z;
18031821
}
18041822
void db_set(const char *zName, const char *zValue, int globalFlag){
18051823
db_begin_transaction();
18061824
if( globalFlag ){
18071825
db_swap_connections();
18081826
--- src/db.c
+++ src/db.c
@@ -1340,10 +1340,11 @@
1340 Blob hash;
1341 Blob manifest;
1342
1343 db_set("content-schema", CONTENT_SCHEMA, 0);
1344 db_set("aux-schema", AUX_SCHEMA, 0);
 
1345 if( makeServerCodes ){
1346 db_multi_exec(
1347 "INSERT INTO config(name,value,mtime)"
1348 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1349 "INSERT INTO config(name,value,mtime)"
@@ -1798,10 +1799,27 @@
1798 }
1799 if( z==0 ){
1800 z = zDefault;
1801 }
1802 return z;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1803 }
1804 void db_set(const char *zName, const char *zValue, int globalFlag){
1805 db_begin_transaction();
1806 if( globalFlag ){
1807 db_swap_connections();
1808
--- src/db.c
+++ src/db.c
@@ -1340,10 +1340,11 @@
1340 Blob hash;
1341 Blob manifest;
1342
1343 db_set("content-schema", CONTENT_SCHEMA, 0);
1344 db_set("aux-schema", AUX_SCHEMA, 0);
1345 db_set("rebuilt", get_version(), 0);
1346 if( makeServerCodes ){
1347 db_multi_exec(
1348 "INSERT INTO config(name,value,mtime)"
1349 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1350 "INSERT INTO config(name,value,mtime)"
@@ -1798,10 +1799,27 @@
1799 }
1800 if( z==0 ){
1801 z = zDefault;
1802 }
1803 return z;
1804 }
1805 char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){
1806 char *z = 0;
1807 if( g.repositoryOpen ){
1808 z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
1809 }
1810 if( z==0 && g.zConfigDbName ){
1811 db_swap_connections();
1812 z = db_text(0, "SELECT mtime FROM global_config WHERE name=%Q", zName);
1813 db_swap_connections();
1814 }
1815 if( z==0 ){
1816 z = zDefault;
1817 }else if( zFormat!=0 ){
1818 z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z);
1819 }
1820 return z;
1821 }
1822 void db_set(const char *zName, const char *zValue, int globalFlag){
1823 db_begin_transaction();
1824 if( globalFlag ){
1825 db_swap_connections();
1826
+9 -2
--- src/main.c
+++ src/main.c
@@ -804,10 +804,18 @@
804804
multi_column_list(aCmd, nCmd);
805805
}
806806
807807
808808
809
+/*
810
+** This function returns a human readable version string.
811
+*/
812
+const char *get_version(){
813
+ static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
814
+ MANIFEST_DATE " UTC";
815
+ return version;
816
+}
809817
810818
/*
811819
** COMMAND: version
812820
**
813821
** Usage: %fossil version ?-verbose|-v?
@@ -816,12 +824,11 @@
816824
** If the verbose option is specified, additional details will
817825
** be output about what optional features this binary was compiled
818826
** with
819827
*/
820828
void version_cmd(void){
821
- fossil_print("This is fossil version " RELEASE_VERSION " "
822
- MANIFEST_VERSION " " MANIFEST_DATE " UTC\n");
829
+ fossil_print("This is fossil version %s\n", get_version());
823830
if(!find_option("verbose","v",0)){
824831
return;
825832
}else{
826833
#if defined(FOSSIL_ENABLE_TCL)
827834
int rc;
828835
--- src/main.c
+++ src/main.c
@@ -804,10 +804,18 @@
804 multi_column_list(aCmd, nCmd);
805 }
806
807
808
 
 
 
 
 
 
 
 
809
810 /*
811 ** COMMAND: version
812 **
813 ** Usage: %fossil version ?-verbose|-v?
@@ -816,12 +824,11 @@
816 ** If the verbose option is specified, additional details will
817 ** be output about what optional features this binary was compiled
818 ** with
819 */
820 void version_cmd(void){
821 fossil_print("This is fossil version " RELEASE_VERSION " "
822 MANIFEST_VERSION " " MANIFEST_DATE " UTC\n");
823 if(!find_option("verbose","v",0)){
824 return;
825 }else{
826 #if defined(FOSSIL_ENABLE_TCL)
827 int rc;
828
--- src/main.c
+++ src/main.c
@@ -804,10 +804,18 @@
804 multi_column_list(aCmd, nCmd);
805 }
806
807
808
809 /*
810 ** This function returns a human readable version string.
811 */
812 const char *get_version(){
813 static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
814 MANIFEST_DATE " UTC";
815 return version;
816 }
817
818 /*
819 ** COMMAND: version
820 **
821 ** Usage: %fossil version ?-verbose|-v?
@@ -816,12 +824,11 @@
824 ** If the verbose option is specified, additional details will
825 ** be output about what optional features this binary was compiled
826 ** with
827 */
828 void version_cmd(void){
829 fossil_print("This is fossil version %s\n", get_version());
 
830 if(!find_option("verbose","v",0)){
831 return;
832 }else{
833 #if defined(FOSSIL_ENABLE_TCL)
834 int rc;
835
+3 -2
--- src/rebuild.c
+++ src/rebuild.c
@@ -581,12 +581,13 @@
581581
ttyOutput = 1;
582582
errCnt = rebuild_db(randomizeFlag, 1, doClustering);
583583
reconstruct_private_table();
584584
db_multi_exec(
585585
"REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());"
586
- "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());",
587
- CONTENT_SCHEMA, AUX_SCHEMA
586
+ "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());"
587
+ "REPLACE INTO config(name,value,mtime) VALUES('rebuilt','%s',now());",
588
+ CONTENT_SCHEMA, AUX_SCHEMA, get_version()
588589
);
589590
if( errCnt && !forceFlag ){
590591
fossil_print(
591592
"%d errors. Rolling back changes. Use --force to force a commit.\n",
592593
errCnt
593594
--- src/rebuild.c
+++ src/rebuild.c
@@ -581,12 +581,13 @@
581 ttyOutput = 1;
582 errCnt = rebuild_db(randomizeFlag, 1, doClustering);
583 reconstruct_private_table();
584 db_multi_exec(
585 "REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());"
586 "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());",
587 CONTENT_SCHEMA, AUX_SCHEMA
 
588 );
589 if( errCnt && !forceFlag ){
590 fossil_print(
591 "%d errors. Rolling back changes. Use --force to force a commit.\n",
592 errCnt
593
--- src/rebuild.c
+++ src/rebuild.c
@@ -581,12 +581,13 @@
581 ttyOutput = 1;
582 errCnt = rebuild_db(randomizeFlag, 1, doClustering);
583 reconstruct_private_table();
584 db_multi_exec(
585 "REPLACE INTO config(name,value,mtime) VALUES('content-schema','%s',now());"
586 "REPLACE INTO config(name,value,mtime) VALUES('aux-schema','%s',now());"
587 "REPLACE INTO config(name,value,mtime) VALUES('rebuilt','%s',now());",
588 CONTENT_SCHEMA, AUX_SCHEMA, get_version()
589 );
590 if( errCnt && !forceFlag ){
591 fossil_print(
592 "%d errors. Rolling back changes. Use --force to force a commit.\n",
593 errCnt
594
+3
--- src/stat.c
+++ src/stat.c
@@ -124,10 +124,13 @@
124124
@ %h(MANIFEST_DATE) %h(MANIFEST_VERSION)
125125
@ (%h(RELEASE_VERSION)) [compiled using %h(COMPILER_NAME)]
126126
@ </td></tr>
127127
@ <tr><th>SQLite&nbsp;Version:</th><td>%.19s(SQLITE_SOURCE_ID)
128128
@ [%.10s(&SQLITE_SOURCE_ID[20])] (%s(SQLITE_VERSION))</td></tr>
129
+ @ <tr><th>Repository Rebuilt:</th><td>
130
+ @ %h(db_get_mtime("rebuilt","%Y-%m-%d %H:%M:%S","Never"))
131
+ @ By Fossil %h(db_get("rebuilt","Unknown"))</td></tr>
129132
@ <tr><th>Database&nbsp;Stats:</th><td>
130133
zDb = db_name("repository");
131134
@ %d(db_int(0, "PRAGMA %s.page_count", zDb)) pages,
132135
@ %d(db_int(0, "PRAGMA %s.page_size", zDb)) bytes/page,
133136
@ %d(db_int(0, "PRAGMA %s.freelist_count", zDb)) free pages,
134137
--- src/stat.c
+++ src/stat.c
@@ -124,10 +124,13 @@
124 @ %h(MANIFEST_DATE) %h(MANIFEST_VERSION)
125 @ (%h(RELEASE_VERSION)) [compiled using %h(COMPILER_NAME)]
126 @ </td></tr>
127 @ <tr><th>SQLite&nbsp;Version:</th><td>%.19s(SQLITE_SOURCE_ID)
128 @ [%.10s(&SQLITE_SOURCE_ID[20])] (%s(SQLITE_VERSION))</td></tr>
 
 
 
129 @ <tr><th>Database&nbsp;Stats:</th><td>
130 zDb = db_name("repository");
131 @ %d(db_int(0, "PRAGMA %s.page_count", zDb)) pages,
132 @ %d(db_int(0, "PRAGMA %s.page_size", zDb)) bytes/page,
133 @ %d(db_int(0, "PRAGMA %s.freelist_count", zDb)) free pages,
134
--- src/stat.c
+++ src/stat.c
@@ -124,10 +124,13 @@
124 @ %h(MANIFEST_DATE) %h(MANIFEST_VERSION)
125 @ (%h(RELEASE_VERSION)) [compiled using %h(COMPILER_NAME)]
126 @ </td></tr>
127 @ <tr><th>SQLite&nbsp;Version:</th><td>%.19s(SQLITE_SOURCE_ID)
128 @ [%.10s(&SQLITE_SOURCE_ID[20])] (%s(SQLITE_VERSION))</td></tr>
129 @ <tr><th>Repository Rebuilt:</th><td>
130 @ %h(db_get_mtime("rebuilt","%Y-%m-%d %H:%M:%S","Never"))
131 @ By Fossil %h(db_get("rebuilt","Unknown"))</td></tr>
132 @ <tr><th>Database&nbsp;Stats:</th><td>
133 zDb = db_name("repository");
134 @ %d(db_int(0, "PRAGMA %s.page_count", zDb)) pages,
135 @ %d(db_int(0, "PRAGMA %s.page_size", zDb)) bytes/page,
136 @ %d(db_int(0, "PRAGMA %s.freelist_count", zDb)) free pages,
137

Keyboard Shortcuts

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