Fossil SCM
If a file in the check-out is changed to something other than a file (like a directory) then raise an error when checking file signatures. Also fix a problem with the new multi-file "revert" command and add some comments to "update".
Commit
d861fe77fbeb26a31c79d5ce39c1eeb0242e506d
Parent
1d9ebd9e4a5a05b…
2 files changed
+13
-10
+7
+13
-10
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -164,16 +164,16 @@ | ||
| 164 | 164 | |
| 165 | 165 | db_prepare(&q, |
| 166 | 166 | "SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1" |
| 167 | 167 | ); |
| 168 | 168 | while( db_step(&q)==SQLITE_ROW ){ |
| 169 | - const char *zName = db_column_text(&q, 0); | |
| 170 | - int idv = db_column_int(&q, 1); | |
| 171 | - int ridv = db_column_int(&q, 2); | |
| 172 | - int idt = db_column_int(&q, 3); | |
| 173 | - int ridt = db_column_int(&q, 4); | |
| 174 | - int chnged = db_column_int(&q, 5); | |
| 169 | + const char *zName = db_column_text(&q, 0); /* The filename */ | |
| 170 | + int idv = db_column_int(&q, 1); /* VFILE entry for current */ | |
| 171 | + int ridv = db_column_int(&q, 2); /* RecordID for current */ | |
| 172 | + int idt = db_column_int(&q, 3); /* VFILE entry for target */ | |
| 173 | + int ridt = db_column_int(&q, 4); /* RecordID for target */ | |
| 174 | + int chnged = db_column_int(&q, 5); /* Current is edited */ | |
| 175 | 175 | |
| 176 | 176 | if( idv>0 && ridv==0 && idt>0 ){ |
| 177 | 177 | /* Conflict. This file has been added to the current checkout |
| 178 | 178 | ** but also exists in the target checkout. Use the current version. |
| 179 | 179 | */ |
| @@ -301,25 +301,28 @@ | ||
| 301 | 301 | const char *zRevision; |
| 302 | 302 | Blob fname; |
| 303 | 303 | Blob record; |
| 304 | 304 | Blob ans; |
| 305 | 305 | int i; |
| 306 | - int rid = 0, yesRevert; | |
| 306 | + int rid = 0; | |
| 307 | + int yesFlag; | |
| 308 | + int yesRevert; | |
| 307 | 309 | |
| 308 | - yesRevert = find_option("yes", "y", 0)!=0; | |
| 310 | + yesFlag = find_option("yes", "y", 0)!=0; | |
| 309 | 311 | zRevision = find_option("revision", "r", 1); |
| 310 | 312 | verify_all_options(); |
| 311 | 313 | |
| 312 | 314 | if( g.argc<3 ){ |
| 313 | 315 | usage("?OPTIONS FILE ..."); |
| 314 | 316 | } |
| 315 | 317 | db_must_be_within_tree(); |
| 316 | 318 | |
| 317 | - for(i=2; i<g.argc; i++){ | |
| 319 | + for(i=2; i<g.argc; i++){ | |
| 318 | 320 | zFile = mprintf("%/", g.argv[i]); |
| 319 | 321 | file_tree_name(zFile, &fname, 1); |
| 320 | - if( access(zFile, 0) ) yesRevert = 1; | |
| 322 | + yesRevert = yesFlag; | |
| 323 | + if( !yesRevert && access(zFile, 0) ) yesRevert = 1; | |
| 321 | 324 | if( yesRevert==0 ){ |
| 322 | 325 | char *prompt = mprintf("revert file %B? this will" |
| 323 | 326 | " destroy local changes (y/N)? ", |
| 324 | 327 | &fname); |
| 325 | 328 | blob_zero(&ans); |
| 326 | 329 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -164,16 +164,16 @@ | |
| 164 | |
| 165 | db_prepare(&q, |
| 166 | "SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1" |
| 167 | ); |
| 168 | while( db_step(&q)==SQLITE_ROW ){ |
| 169 | const char *zName = db_column_text(&q, 0); |
| 170 | int idv = db_column_int(&q, 1); |
| 171 | int ridv = db_column_int(&q, 2); |
| 172 | int idt = db_column_int(&q, 3); |
| 173 | int ridt = db_column_int(&q, 4); |
| 174 | int chnged = db_column_int(&q, 5); |
| 175 | |
| 176 | if( idv>0 && ridv==0 && idt>0 ){ |
| 177 | /* Conflict. This file has been added to the current checkout |
| 178 | ** but also exists in the target checkout. Use the current version. |
| 179 | */ |
| @@ -301,25 +301,28 @@ | |
| 301 | const char *zRevision; |
| 302 | Blob fname; |
| 303 | Blob record; |
| 304 | Blob ans; |
| 305 | int i; |
| 306 | int rid = 0, yesRevert; |
| 307 | |
| 308 | yesRevert = find_option("yes", "y", 0)!=0; |
| 309 | zRevision = find_option("revision", "r", 1); |
| 310 | verify_all_options(); |
| 311 | |
| 312 | if( g.argc<3 ){ |
| 313 | usage("?OPTIONS FILE ..."); |
| 314 | } |
| 315 | db_must_be_within_tree(); |
| 316 | |
| 317 | for(i=2; i<g.argc; i++){ |
| 318 | zFile = mprintf("%/", g.argv[i]); |
| 319 | file_tree_name(zFile, &fname, 1); |
| 320 | if( access(zFile, 0) ) yesRevert = 1; |
| 321 | if( yesRevert==0 ){ |
| 322 | char *prompt = mprintf("revert file %B? this will" |
| 323 | " destroy local changes (y/N)? ", |
| 324 | &fname); |
| 325 | blob_zero(&ans); |
| 326 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -164,16 +164,16 @@ | |
| 164 | |
| 165 | db_prepare(&q, |
| 166 | "SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1" |
| 167 | ); |
| 168 | while( db_step(&q)==SQLITE_ROW ){ |
| 169 | const char *zName = db_column_text(&q, 0); /* The filename */ |
| 170 | int idv = db_column_int(&q, 1); /* VFILE entry for current */ |
| 171 | int ridv = db_column_int(&q, 2); /* RecordID for current */ |
| 172 | int idt = db_column_int(&q, 3); /* VFILE entry for target */ |
| 173 | int ridt = db_column_int(&q, 4); /* RecordID for target */ |
| 174 | int chnged = db_column_int(&q, 5); /* Current is edited */ |
| 175 | |
| 176 | if( idv>0 && ridv==0 && idt>0 ){ |
| 177 | /* Conflict. This file has been added to the current checkout |
| 178 | ** but also exists in the target checkout. Use the current version. |
| 179 | */ |
| @@ -301,25 +301,28 @@ | |
| 301 | const char *zRevision; |
| 302 | Blob fname; |
| 303 | Blob record; |
| 304 | Blob ans; |
| 305 | int i; |
| 306 | int rid = 0; |
| 307 | int yesFlag; |
| 308 | int yesRevert; |
| 309 | |
| 310 | yesFlag = find_option("yes", "y", 0)!=0; |
| 311 | zRevision = find_option("revision", "r", 1); |
| 312 | verify_all_options(); |
| 313 | |
| 314 | if( g.argc<3 ){ |
| 315 | usage("?OPTIONS FILE ..."); |
| 316 | } |
| 317 | db_must_be_within_tree(); |
| 318 | |
| 319 | for(i=2; i<g.argc; i++){ |
| 320 | zFile = mprintf("%/", g.argv[i]); |
| 321 | file_tree_name(zFile, &fname, 1); |
| 322 | yesRevert = yesFlag; |
| 323 | if( !yesRevert && access(zFile, 0) ) yesRevert = 1; |
| 324 | if( yesRevert==0 ){ |
| 325 | char *prompt = mprintf("revert file %B? this will" |
| 326 | " destroy local changes (y/N)? ", |
| 327 | &fname); |
| 328 | blob_zero(&ans); |
| 329 |
+7
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -143,10 +143,11 @@ | ||
| 143 | 143 | ** |
| 144 | 144 | ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume |
| 145 | 145 | ** the file has changed without having the check the on-disk image. |
| 146 | 146 | */ |
| 147 | 147 | void vfile_check_signature(int vid){ |
| 148 | + int nErr = 0; | |
| 148 | 149 | Stmt q; |
| 149 | 150 | Blob fileCksum, origCksum; |
| 150 | 151 | int checkMtime = db_get_boolean("mtime-changes", 0); |
| 151 | 152 | |
| 152 | 153 | db_begin_transaction(); |
| @@ -166,10 +167,15 @@ | ||
| 166 | 167 | zName = db_column_text(&q, 1); |
| 167 | 168 | rid = db_column_int(&q, 2); |
| 168 | 169 | isDeleted = db_column_int(&q, 3); |
| 169 | 170 | oldChnged = db_column_int(&q, 4); |
| 170 | 171 | oldMtime = db_column_int64(&q, 6); |
| 172 | + if( !file_isfile(zName) && file_size(zName)>=0 ){ | |
| 173 | + fossil_warning("not a ordinary file: %s", zName); | |
| 174 | + nErr++; | |
| 175 | + continue; | |
| 176 | + } | |
| 171 | 177 | if( oldChnged>=2 ){ |
| 172 | 178 | chnged = oldChnged; |
| 173 | 179 | }else if( isDeleted || rid==0 ){ |
| 174 | 180 | chnged = 1; |
| 175 | 181 | } |
| @@ -193,10 +199,11 @@ | ||
| 193 | 199 | if( chnged!=oldChnged ){ |
| 194 | 200 | db_multi_exec("UPDATE vfile SET chnged=%d WHERE id=%d", chnged, id); |
| 195 | 201 | } |
| 196 | 202 | } |
| 197 | 203 | db_finalize(&q); |
| 204 | + if( nErr ) fossil_fatal("abort due to prior errors"); | |
| 198 | 205 | db_end_transaction(0); |
| 199 | 206 | } |
| 200 | 207 | |
| 201 | 208 | /* |
| 202 | 209 | ** Write all files from vid to the disk. Or if vid==0 and id!=0 |
| 203 | 210 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -143,10 +143,11 @@ | |
| 143 | ** |
| 144 | ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume |
| 145 | ** the file has changed without having the check the on-disk image. |
| 146 | */ |
| 147 | void vfile_check_signature(int vid){ |
| 148 | Stmt q; |
| 149 | Blob fileCksum, origCksum; |
| 150 | int checkMtime = db_get_boolean("mtime-changes", 0); |
| 151 | |
| 152 | db_begin_transaction(); |
| @@ -166,10 +167,15 @@ | |
| 166 | zName = db_column_text(&q, 1); |
| 167 | rid = db_column_int(&q, 2); |
| 168 | isDeleted = db_column_int(&q, 3); |
| 169 | oldChnged = db_column_int(&q, 4); |
| 170 | oldMtime = db_column_int64(&q, 6); |
| 171 | if( oldChnged>=2 ){ |
| 172 | chnged = oldChnged; |
| 173 | }else if( isDeleted || rid==0 ){ |
| 174 | chnged = 1; |
| 175 | } |
| @@ -193,10 +199,11 @@ | |
| 193 | if( chnged!=oldChnged ){ |
| 194 | db_multi_exec("UPDATE vfile SET chnged=%d WHERE id=%d", chnged, id); |
| 195 | } |
| 196 | } |
| 197 | db_finalize(&q); |
| 198 | db_end_transaction(0); |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | ** Write all files from vid to the disk. Or if vid==0 and id!=0 |
| 203 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -143,10 +143,11 @@ | |
| 143 | ** |
| 144 | ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume |
| 145 | ** the file has changed without having the check the on-disk image. |
| 146 | */ |
| 147 | void vfile_check_signature(int vid){ |
| 148 | int nErr = 0; |
| 149 | Stmt q; |
| 150 | Blob fileCksum, origCksum; |
| 151 | int checkMtime = db_get_boolean("mtime-changes", 0); |
| 152 | |
| 153 | db_begin_transaction(); |
| @@ -166,10 +167,15 @@ | |
| 167 | zName = db_column_text(&q, 1); |
| 168 | rid = db_column_int(&q, 2); |
| 169 | isDeleted = db_column_int(&q, 3); |
| 170 | oldChnged = db_column_int(&q, 4); |
| 171 | oldMtime = db_column_int64(&q, 6); |
| 172 | if( !file_isfile(zName) && file_size(zName)>=0 ){ |
| 173 | fossil_warning("not a ordinary file: %s", zName); |
| 174 | nErr++; |
| 175 | continue; |
| 176 | } |
| 177 | if( oldChnged>=2 ){ |
| 178 | chnged = oldChnged; |
| 179 | }else if( isDeleted || rid==0 ){ |
| 180 | chnged = 1; |
| 181 | } |
| @@ -193,10 +199,11 @@ | |
| 199 | if( chnged!=oldChnged ){ |
| 200 | db_multi_exec("UPDATE vfile SET chnged=%d WHERE id=%d", chnged, id); |
| 201 | } |
| 202 | } |
| 203 | db_finalize(&q); |
| 204 | if( nErr ) fossil_fatal("abort due to prior errors"); |
| 205 | db_end_transaction(0); |
| 206 | } |
| 207 | |
| 208 | /* |
| 209 | ** Write all files from vid to the disk. Or if vid==0 and id!=0 |
| 210 |