Fossil SCM
Add the test-erase-content command.
Commit
e709bf16e7708359140da40a0fb5bb3b43b80943
Parent
4c8e6d91d2dd8b3…
1 file changed
+40
-1
+40
-1
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -905,11 +905,11 @@ | ||
| 905 | 905 | rid, size, blob_size(&content)); |
| 906 | 906 | nErr++; |
| 907 | 907 | } |
| 908 | 908 | sha1sum_blob(&content, &cksum); |
| 909 | 909 | if( fossil_strcmp(blob_str(&cksum), zUuid)!=0 ){ |
| 910 | - fossil_print("checksum mismatch on artifact %d: wanted %s but got %s\n", | |
| 910 | + fossil_print("wrong hash on artifact %d: wanted %s but got %s\n", | |
| 911 | 911 | rid, zUuid, blob_str(&cksum)); |
| 912 | 912 | nErr++; |
| 913 | 913 | } |
| 914 | 914 | if( bParse && looks_like_control_artifact(&content) ){ |
| 915 | 915 | Blob err; |
| @@ -1124,5 +1124,44 @@ | ||
| 1124 | 1124 | if( nErr>0 || quietFlag==0 ){ |
| 1125 | 1125 | fossil_print("%d missing or shunned references in %d control artifacts\n", |
| 1126 | 1126 | nErr, nArtifact); |
| 1127 | 1127 | } |
| 1128 | 1128 | } |
| 1129 | + | |
| 1130 | +/* | |
| 1131 | +** COMMAND: test-content-erase | |
| 1132 | +** | |
| 1133 | +** Usage: %fossil test-content-erase RID .... | |
| 1134 | +** | |
| 1135 | +** Remove all traces of one or more artifacts from the local repository. | |
| 1136 | +** | |
| 1137 | +** WARNING: This command destroys data and can cause you to lose work. | |
| 1138 | +** Make sure you have a backup copy before using this command! | |
| 1139 | +** | |
| 1140 | +** WARNING: You must run "fossil rebuild" after this command to rebuild | |
| 1141 | +** the metadata. | |
| 1142 | +** | |
| 1143 | +** Note that the arguments are the integer raw RID values from the BLOB table, | |
| 1144 | +** not SHA1 hashs or labels. | |
| 1145 | +*/ | |
| 1146 | +void test_content_erase(void){ | |
| 1147 | + int i; | |
| 1148 | + Blob x; | |
| 1149 | + char c; | |
| 1150 | + prompt_user("This command erases information from the repository and\n" | |
| 1151 | + "might irrecoverably damage the repository. Make sure you\n" | |
| 1152 | + "have a backup copy!\n" | |
| 1153 | + "Continue? (y/N)? ", &x); | |
| 1154 | + c = blob_str(&x)[0]; | |
| 1155 | + blob_reset(&x); | |
| 1156 | + if( c!='y' && c!='Y' ) return; | |
| 1157 | + db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); | |
| 1158 | + db_begin_transaction(); | |
| 1159 | + for(i=2; i<g.argc; i++){ | |
| 1160 | + int rid = atoi(g.argv[i]); | |
| 1161 | + fossil_print("Erasing artifact %d (%s)\n", | |
| 1162 | + rid, db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid)); | |
| 1163 | + content_undelta(rid); | |
| 1164 | + db_multi_exec("DELETE FROM blob WHERE rid=%d", rid); | |
| 1165 | + } | |
| 1166 | + db_end_transaction(0); | |
| 1167 | +} | |
| 1129 | 1168 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -905,11 +905,11 @@ | |
| 905 | rid, size, blob_size(&content)); |
| 906 | nErr++; |
| 907 | } |
| 908 | sha1sum_blob(&content, &cksum); |
| 909 | if( fossil_strcmp(blob_str(&cksum), zUuid)!=0 ){ |
| 910 | fossil_print("checksum mismatch on artifact %d: wanted %s but got %s\n", |
| 911 | rid, zUuid, blob_str(&cksum)); |
| 912 | nErr++; |
| 913 | } |
| 914 | if( bParse && looks_like_control_artifact(&content) ){ |
| 915 | Blob err; |
| @@ -1124,5 +1124,44 @@ | |
| 1124 | if( nErr>0 || quietFlag==0 ){ |
| 1125 | fossil_print("%d missing or shunned references in %d control artifacts\n", |
| 1126 | nErr, nArtifact); |
| 1127 | } |
| 1128 | } |
| 1129 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -905,11 +905,11 @@ | |
| 905 | rid, size, blob_size(&content)); |
| 906 | nErr++; |
| 907 | } |
| 908 | sha1sum_blob(&content, &cksum); |
| 909 | if( fossil_strcmp(blob_str(&cksum), zUuid)!=0 ){ |
| 910 | fossil_print("wrong hash on artifact %d: wanted %s but got %s\n", |
| 911 | rid, zUuid, blob_str(&cksum)); |
| 912 | nErr++; |
| 913 | } |
| 914 | if( bParse && looks_like_control_artifact(&content) ){ |
| 915 | Blob err; |
| @@ -1124,5 +1124,44 @@ | |
| 1124 | if( nErr>0 || quietFlag==0 ){ |
| 1125 | fossil_print("%d missing or shunned references in %d control artifacts\n", |
| 1126 | nErr, nArtifact); |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | /* |
| 1131 | ** COMMAND: test-content-erase |
| 1132 | ** |
| 1133 | ** Usage: %fossil test-content-erase RID .... |
| 1134 | ** |
| 1135 | ** Remove all traces of one or more artifacts from the local repository. |
| 1136 | ** |
| 1137 | ** WARNING: This command destroys data and can cause you to lose work. |
| 1138 | ** Make sure you have a backup copy before using this command! |
| 1139 | ** |
| 1140 | ** WARNING: You must run "fossil rebuild" after this command to rebuild |
| 1141 | ** the metadata. |
| 1142 | ** |
| 1143 | ** Note that the arguments are the integer raw RID values from the BLOB table, |
| 1144 | ** not SHA1 hashs or labels. |
| 1145 | */ |
| 1146 | void test_content_erase(void){ |
| 1147 | int i; |
| 1148 | Blob x; |
| 1149 | char c; |
| 1150 | prompt_user("This command erases information from the repository and\n" |
| 1151 | "might irrecoverably damage the repository. Make sure you\n" |
| 1152 | "have a backup copy!\n" |
| 1153 | "Continue? (y/N)? ", &x); |
| 1154 | c = blob_str(&x)[0]; |
| 1155 | blob_reset(&x); |
| 1156 | if( c!='y' && c!='Y' ) return; |
| 1157 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 1158 | db_begin_transaction(); |
| 1159 | for(i=2; i<g.argc; i++){ |
| 1160 | int rid = atoi(g.argv[i]); |
| 1161 | fossil_print("Erasing artifact %d (%s)\n", |
| 1162 | rid, db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid)); |
| 1163 | content_undelta(rid); |
| 1164 | db_multi_exec("DELETE FROM blob WHERE rid=%d", rid); |
| 1165 | } |
| 1166 | db_end_transaction(0); |
| 1167 | } |
| 1168 |