Fossil SCM
Add the --db-verify option to the "fossil dbstat" command. This option simply runs "fossil test-integrity" after doing the other dbstat processing. It is a way to access the test-integrity functionality without using the (unsupported) "test-integrity" command.
Commit
95e91b13d28d62c04cf740a4ac844b85aa170aa2e35ce4be45453aeb9dc69fbc
Parent
98fa23f90b11394…
2 files changed
+1
+22
-6
+1
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -219,10 +219,11 @@ | ||
| 219 | 219 | zCmd = "dbstat --omit-version-info -R"; |
| 220 | 220 | showLabel = 1; |
| 221 | 221 | quiet = 1; |
| 222 | 222 | collect_argument(&extra, "brief", "b"); |
| 223 | 223 | collect_argument(&extra, "db-check", 0); |
| 224 | + collect_argument(&extra, "db-verify", 0); | |
| 224 | 225 | }else if( strncmp(zCmd, "extras", n)==0 ){ |
| 225 | 226 | if( showFile ){ |
| 226 | 227 | zCmd = "extras --chdir"; |
| 227 | 228 | }else{ |
| 228 | 229 | zCmd = "extras --header --chdir"; |
| 229 | 230 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -219,10 +219,11 @@ | |
| 219 | zCmd = "dbstat --omit-version-info -R"; |
| 220 | showLabel = 1; |
| 221 | quiet = 1; |
| 222 | collect_argument(&extra, "brief", "b"); |
| 223 | collect_argument(&extra, "db-check", 0); |
| 224 | }else if( strncmp(zCmd, "extras", n)==0 ){ |
| 225 | if( showFile ){ |
| 226 | zCmd = "extras --chdir"; |
| 227 | }else{ |
| 228 | zCmd = "extras --header --chdir"; |
| 229 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -219,10 +219,11 @@ | |
| 219 | zCmd = "dbstat --omit-version-info -R"; |
| 220 | showLabel = 1; |
| 221 | quiet = 1; |
| 222 | collect_argument(&extra, "brief", "b"); |
| 223 | collect_argument(&extra, "db-check", 0); |
| 224 | collect_argument(&extra, "db-verify", 0); |
| 225 | }else if( strncmp(zCmd, "extras", n)==0 ){ |
| 226 | if( showFile ){ |
| 227 | zCmd = "extras --chdir"; |
| 228 | }else{ |
| 229 | zCmd = "extras --header --chdir"; |
| 230 |
+22
-6
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -296,17 +296,21 @@ | ||
| 296 | 296 | /* |
| 297 | 297 | ** COMMAND: dbstat |
| 298 | 298 | ** |
| 299 | 299 | ** Usage: %fossil dbstat OPTIONS |
| 300 | 300 | ** |
| 301 | -** Shows statistics and global information about the repository. | |
| 301 | +** Shows statistics and global information about the repository and/or | |
| 302 | +** verify the integrity of a repository. | |
| 302 | 303 | ** |
| 303 | 304 | ** Options: |
| 304 | 305 | ** |
| 305 | -** --brief|-b Only show essential elements | |
| 306 | -** --db-check Run a PRAGMA quick_check on the repository database | |
| 307 | -** --omit-version-info Omit the SQLite and Fossil version information | |
| 306 | +** --brief|-b Only show essential elements. | |
| 307 | +** --db-check Run "PRAGMA quick_check" on the repository database. | |
| 308 | +** --db-verify Run a full verification of the repository integrity. | |
| 309 | +** This involves decoding and reparsing all artifacts | |
| 310 | +** and can take significant time. | |
| 311 | +** --omit-version-info Omit the SQLite and Fossil version information. | |
| 308 | 312 | */ |
| 309 | 313 | void dbstat_cmd(void){ |
| 310 | 314 | i64 t, fsize; |
| 311 | 315 | int n, m; |
| 312 | 316 | int szMax, szAvg; |
| @@ -317,10 +321,11 @@ | ||
| 317 | 321 | const char *p, *z; |
| 318 | 322 | |
| 319 | 323 | brief = find_option("brief", "b",0)!=0; |
| 320 | 324 | omitVers = find_option("omit-version-info", 0, 0)!=0; |
| 321 | 325 | dbCheck = find_option("db-check",0,0)!=0; |
| 326 | + if( find_option("db-verify",0,0)!=0 ) dbCheck = 2; | |
| 322 | 327 | db_find_and_open_repository(0,0); |
| 323 | 328 | |
| 324 | 329 | /* We should be done with options.. */ |
| 325 | 330 | verify_all_options(); |
| 326 | 331 | |
| @@ -414,12 +419,23 @@ | ||
| 414 | 419 | db_int(0, "PRAGMA repository.page_size"), |
| 415 | 420 | db_int(0, "PRAGMA repository.freelist_count"), |
| 416 | 421 | db_text(0, "PRAGMA repository.encoding"), |
| 417 | 422 | db_text(0, "PRAGMA repository.journal_mode")); |
| 418 | 423 | if( dbCheck ){ |
| 419 | - fossil_print("%*s%s\n", colWidth, "database-check:", | |
| 420 | - db_text(0, "PRAGMA quick_check(1)")); | |
| 424 | + if( dbCheck<2 ){ | |
| 425 | + char *zRes = db_text(0, "PRAGMA repository.quick_check(1)"); | |
| 426 | + fossil_print("%*s%s\n", colWidth, "database-check:", zRes); | |
| 427 | + }else{ | |
| 428 | + char *newArgv[2]; | |
| 429 | + newArgv[0] = g.argv[0]; | |
| 430 | + newArgv[1] = "test-integrity"; | |
| 431 | + newArgv[2] = 0; | |
| 432 | + g.argv = newArgv; | |
| 433 | + g.argc = 2; | |
| 434 | + fossil_print("Full repository verification follows:\n"); | |
| 435 | + test_integrity(); | |
| 436 | + } | |
| 421 | 437 | } |
| 422 | 438 | } |
| 423 | 439 | |
| 424 | 440 | /* |
| 425 | 441 | ** WEBPAGE: urllist |
| 426 | 442 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -296,17 +296,21 @@ | |
| 296 | /* |
| 297 | ** COMMAND: dbstat |
| 298 | ** |
| 299 | ** Usage: %fossil dbstat OPTIONS |
| 300 | ** |
| 301 | ** Shows statistics and global information about the repository. |
| 302 | ** |
| 303 | ** Options: |
| 304 | ** |
| 305 | ** --brief|-b Only show essential elements |
| 306 | ** --db-check Run a PRAGMA quick_check on the repository database |
| 307 | ** --omit-version-info Omit the SQLite and Fossil version information |
| 308 | */ |
| 309 | void dbstat_cmd(void){ |
| 310 | i64 t, fsize; |
| 311 | int n, m; |
| 312 | int szMax, szAvg; |
| @@ -317,10 +321,11 @@ | |
| 317 | const char *p, *z; |
| 318 | |
| 319 | brief = find_option("brief", "b",0)!=0; |
| 320 | omitVers = find_option("omit-version-info", 0, 0)!=0; |
| 321 | dbCheck = find_option("db-check",0,0)!=0; |
| 322 | db_find_and_open_repository(0,0); |
| 323 | |
| 324 | /* We should be done with options.. */ |
| 325 | verify_all_options(); |
| 326 | |
| @@ -414,12 +419,23 @@ | |
| 414 | db_int(0, "PRAGMA repository.page_size"), |
| 415 | db_int(0, "PRAGMA repository.freelist_count"), |
| 416 | db_text(0, "PRAGMA repository.encoding"), |
| 417 | db_text(0, "PRAGMA repository.journal_mode")); |
| 418 | if( dbCheck ){ |
| 419 | fossil_print("%*s%s\n", colWidth, "database-check:", |
| 420 | db_text(0, "PRAGMA quick_check(1)")); |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | /* |
| 425 | ** WEBPAGE: urllist |
| 426 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -296,17 +296,21 @@ | |
| 296 | /* |
| 297 | ** COMMAND: dbstat |
| 298 | ** |
| 299 | ** Usage: %fossil dbstat OPTIONS |
| 300 | ** |
| 301 | ** Shows statistics and global information about the repository and/or |
| 302 | ** verify the integrity of a repository. |
| 303 | ** |
| 304 | ** Options: |
| 305 | ** |
| 306 | ** --brief|-b Only show essential elements. |
| 307 | ** --db-check Run "PRAGMA quick_check" on the repository database. |
| 308 | ** --db-verify Run a full verification of the repository integrity. |
| 309 | ** This involves decoding and reparsing all artifacts |
| 310 | ** and can take significant time. |
| 311 | ** --omit-version-info Omit the SQLite and Fossil version information. |
| 312 | */ |
| 313 | void dbstat_cmd(void){ |
| 314 | i64 t, fsize; |
| 315 | int n, m; |
| 316 | int szMax, szAvg; |
| @@ -317,10 +321,11 @@ | |
| 321 | const char *p, *z; |
| 322 | |
| 323 | brief = find_option("brief", "b",0)!=0; |
| 324 | omitVers = find_option("omit-version-info", 0, 0)!=0; |
| 325 | dbCheck = find_option("db-check",0,0)!=0; |
| 326 | if( find_option("db-verify",0,0)!=0 ) dbCheck = 2; |
| 327 | db_find_and_open_repository(0,0); |
| 328 | |
| 329 | /* We should be done with options.. */ |
| 330 | verify_all_options(); |
| 331 | |
| @@ -414,12 +419,23 @@ | |
| 419 | db_int(0, "PRAGMA repository.page_size"), |
| 420 | db_int(0, "PRAGMA repository.freelist_count"), |
| 421 | db_text(0, "PRAGMA repository.encoding"), |
| 422 | db_text(0, "PRAGMA repository.journal_mode")); |
| 423 | if( dbCheck ){ |
| 424 | if( dbCheck<2 ){ |
| 425 | char *zRes = db_text(0, "PRAGMA repository.quick_check(1)"); |
| 426 | fossil_print("%*s%s\n", colWidth, "database-check:", zRes); |
| 427 | }else{ |
| 428 | char *newArgv[2]; |
| 429 | newArgv[0] = g.argv[0]; |
| 430 | newArgv[1] = "test-integrity"; |
| 431 | newArgv[2] = 0; |
| 432 | g.argv = newArgv; |
| 433 | g.argc = 2; |
| 434 | fossil_print("Full repository verification follows:\n"); |
| 435 | test_integrity(); |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | /* |
| 441 | ** WEBPAGE: urllist |
| 442 |