Fossil SCM
Fix to the test-content-erase command so that it correctly undeltafies.
Commit
d0cabcb617b05ce4e05e391f50abaf7299a7a1b8
Parent
00bfa66e6c921cb…
1 file changed
+9
-1
+9
-1
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -1147,23 +1147,31 @@ | ||
| 1147 | 1147 | */ |
| 1148 | 1148 | void test_content_erase(void){ |
| 1149 | 1149 | int i; |
| 1150 | 1150 | Blob x; |
| 1151 | 1151 | char c; |
| 1152 | + Stmt q; | |
| 1152 | 1153 | prompt_user("This command erases information from the repository and\n" |
| 1153 | 1154 | "might irrecoverably damage the repository. Make sure you\n" |
| 1154 | 1155 | "have a backup copy!\n" |
| 1155 | 1156 | "Continue? (y/N)? ", &x); |
| 1156 | 1157 | c = blob_str(&x)[0]; |
| 1157 | 1158 | blob_reset(&x); |
| 1158 | 1159 | if( c!='y' && c!='Y' ) return; |
| 1159 | 1160 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 1160 | 1161 | db_begin_transaction(); |
| 1162 | + db_prepare(&q, "SELECT rid FROM delta WHERE srcid=:rid"); | |
| 1161 | 1163 | for(i=2; i<g.argc; i++){ |
| 1162 | 1164 | int rid = atoi(g.argv[i]); |
| 1163 | 1165 | fossil_print("Erasing artifact %d (%s)\n", |
| 1164 | 1166 | rid, db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid)); |
| 1165 | - content_undelta(rid); | |
| 1167 | + db_bind_int(&q, ":rid", rid); | |
| 1168 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 1169 | + content_undelta(db_column_int(&q,0)); | |
| 1170 | + } | |
| 1171 | + db_reset(&q); | |
| 1166 | 1172 | db_multi_exec("DELETE FROM blob WHERE rid=%d", rid); |
| 1173 | + db_multi_exec("DELETE FROM delta WHERE rid=%d", rid); | |
| 1167 | 1174 | } |
| 1175 | + db_finalize(&q); | |
| 1168 | 1176 | db_end_transaction(0); |
| 1169 | 1177 | } |
| 1170 | 1178 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -1147,23 +1147,31 @@ | |
| 1147 | */ |
| 1148 | void test_content_erase(void){ |
| 1149 | int i; |
| 1150 | Blob x; |
| 1151 | char c; |
| 1152 | prompt_user("This command erases information from the repository and\n" |
| 1153 | "might irrecoverably damage the repository. Make sure you\n" |
| 1154 | "have a backup copy!\n" |
| 1155 | "Continue? (y/N)? ", &x); |
| 1156 | c = blob_str(&x)[0]; |
| 1157 | blob_reset(&x); |
| 1158 | if( c!='y' && c!='Y' ) return; |
| 1159 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 1160 | db_begin_transaction(); |
| 1161 | for(i=2; i<g.argc; i++){ |
| 1162 | int rid = atoi(g.argv[i]); |
| 1163 | fossil_print("Erasing artifact %d (%s)\n", |
| 1164 | rid, db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid)); |
| 1165 | content_undelta(rid); |
| 1166 | db_multi_exec("DELETE FROM blob WHERE rid=%d", rid); |
| 1167 | } |
| 1168 | db_end_transaction(0); |
| 1169 | } |
| 1170 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -1147,23 +1147,31 @@ | |
| 1147 | */ |
| 1148 | void test_content_erase(void){ |
| 1149 | int i; |
| 1150 | Blob x; |
| 1151 | char c; |
| 1152 | Stmt q; |
| 1153 | prompt_user("This command erases information from the repository and\n" |
| 1154 | "might irrecoverably damage the repository. Make sure you\n" |
| 1155 | "have a backup copy!\n" |
| 1156 | "Continue? (y/N)? ", &x); |
| 1157 | c = blob_str(&x)[0]; |
| 1158 | blob_reset(&x); |
| 1159 | if( c!='y' && c!='Y' ) return; |
| 1160 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 1161 | db_begin_transaction(); |
| 1162 | db_prepare(&q, "SELECT rid FROM delta WHERE srcid=:rid"); |
| 1163 | for(i=2; i<g.argc; i++){ |
| 1164 | int rid = atoi(g.argv[i]); |
| 1165 | fossil_print("Erasing artifact %d (%s)\n", |
| 1166 | rid, db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid)); |
| 1167 | db_bind_int(&q, ":rid", rid); |
| 1168 | while( db_step(&q)==SQLITE_ROW ){ |
| 1169 | content_undelta(db_column_int(&q,0)); |
| 1170 | } |
| 1171 | db_reset(&q); |
| 1172 | db_multi_exec("DELETE FROM blob WHERE rid=%d", rid); |
| 1173 | db_multi_exec("DELETE FROM delta WHERE rid=%d", rid); |
| 1174 | } |
| 1175 | db_finalize(&q); |
| 1176 | db_end_transaction(0); |
| 1177 | } |
| 1178 |