Fossil SCM

Fix to the test-content-erase command so that it correctly undeltafies.

drh 2016-01-18 23:46 trunk
Commit d0cabcb617b05ce4e05e391f50abaf7299a7a1b8
1 file changed +9 -1
+9 -1
--- src/content.c
+++ src/content.c
@@ -1147,23 +1147,31 @@
11471147
*/
11481148
void test_content_erase(void){
11491149
int i;
11501150
Blob x;
11511151
char c;
1152
+ Stmt q;
11521153
prompt_user("This command erases information from the repository and\n"
11531154
"might irrecoverably damage the repository. Make sure you\n"
11541155
"have a backup copy!\n"
11551156
"Continue? (y/N)? ", &x);
11561157
c = blob_str(&x)[0];
11571158
blob_reset(&x);
11581159
if( c!='y' && c!='Y' ) return;
11591160
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
11601161
db_begin_transaction();
1162
+ db_prepare(&q, "SELECT rid FROM delta WHERE srcid=:rid");
11611163
for(i=2; i<g.argc; i++){
11621164
int rid = atoi(g.argv[i]);
11631165
fossil_print("Erasing artifact %d (%s)\n",
11641166
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);
11661172
db_multi_exec("DELETE FROM blob WHERE rid=%d", rid);
1173
+ db_multi_exec("DELETE FROM delta WHERE rid=%d", rid);
11671174
}
1175
+ db_finalize(&q);
11681176
db_end_transaction(0);
11691177
}
11701178
--- 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

Keyboard Shortcuts

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