| | @@ -37,14 +37,15 @@ |
| 37 | 37 | ** If the randomize parameter is true, then the BLOBs are deliberately |
| 38 | 38 | ** extracted in a random order. This feature is used to test the |
| 39 | 39 | ** ability of fossil to accept records in any order and still |
| 40 | 40 | ** construct a sane repository. |
| 41 | 41 | */ |
| 42 | | -int rebuild_db(int randomize){ |
| 42 | +int rebuild_db(int randomize, int ttyOutput){ |
| 43 | 43 | Stmt s; |
| 44 | 44 | int errCnt = 0; |
| 45 | 45 | char *zTable; |
| 46 | + int cnt = 0; |
| 46 | 47 | |
| 47 | 48 | db_multi_exec( |
| 48 | 49 | "CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);" |
| 49 | 50 | "CREATE TABLE IF NOT EXISTS shun(uuid UNIQUE);" |
| 50 | 51 | ); |
| | @@ -75,16 +76,25 @@ |
| 75 | 76 | while( db_step(&s)==SQLITE_ROW ){ |
| 76 | 77 | int rid = db_column_int(&s, 0); |
| 77 | 78 | int size = db_column_int(&s, 1); |
| 78 | 79 | if( size>=0 ){ |
| 79 | 80 | Blob content; |
| 81 | + if( ttyOutput ){ |
| 82 | + cnt++; |
| 83 | + printf("%d...\r", cnt); |
| 84 | + fflush(stdout); |
| 85 | + } |
| 80 | 86 | content_get(rid, &content); |
| 81 | 87 | manifest_crosslink(rid, &content); |
| 82 | 88 | blob_reset(&content); |
| 83 | 89 | }else{ |
| 84 | 90 | db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); |
| 85 | 91 | } |
| 92 | + } |
| 93 | + db_finalize(&s); |
| 94 | + if( ttyOutput ){ |
| 95 | + printf("\n"); |
| 86 | 96 | } |
| 87 | 97 | return errCnt; |
| 88 | 98 | } |
| 89 | 99 | |
| 90 | 100 | /* |
| | @@ -106,14 +116,14 @@ |
| 106 | 116 | if( g.argc!=3 ){ |
| 107 | 117 | usage("REPOSITORY-FILENAME"); |
| 108 | 118 | } |
| 109 | 119 | db_open_repository(g.argv[2]); |
| 110 | 120 | db_begin_transaction(); |
| 111 | | - errCnt = rebuild_db(randomizeFlag); |
| 121 | + errCnt = rebuild_db(randomizeFlag, 1); |
| 112 | 122 | if( errCnt && !forceFlag ){ |
| 113 | 123 | printf("%d errors. Rolling back changes. Use --force to force a commit.\n", |
| 114 | 124 | errCnt); |
| 115 | 125 | db_end_transaction(1); |
| 116 | 126 | }else{ |
| 117 | 127 | db_end_transaction(0); |
| 118 | 128 | } |
| 119 | 129 | } |
| 120 | 130 | |