Fossil SCM
Add new warnings for when Fossil overwrites an unmanged file on "update" or "merge". Undo has been and continues to be available to recover the overwritten files.
Commit
39f979b08c4cf075a250e0d48d68144b2e0c3b0e
Parent
fd486df4926a46e…
2 files changed
+18
-4
+19
-8
+18
-4
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -73,10 +73,11 @@ | ||
| 73 | 73 | int debugFlag; /* True if --debug is present */ |
| 74 | 74 | int nChng; /* Number of file name changes */ |
| 75 | 75 | int *aChng; /* An array of file name changes */ |
| 76 | 76 | int i; /* Loop counter */ |
| 77 | 77 | int nConflict = 0; /* Number of conflicts seen */ |
| 78 | + int nOverwrite = 0; /* Number of unmanaged files overwritten */ | |
| 78 | 79 | int caseSensitive; /* True for case-sensitive filenames */ |
| 79 | 80 | Stmt q; |
| 80 | 81 | |
| 81 | 82 | |
| 82 | 83 | /* Notation: |
| @@ -319,19 +320,27 @@ | ||
| 319 | 320 | while( db_step(&q)==SQLITE_ROW ){ |
| 320 | 321 | int idm = db_column_int(&q, 0); |
| 321 | 322 | int rowid = db_column_int(&q, 1); |
| 322 | 323 | int idv; |
| 323 | 324 | const char *zName; |
| 325 | + const char *zFullName; | |
| 324 | 326 | db_multi_exec( |
| 325 | 327 | "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)" |
| 326 | 328 | " SELECT %d,3,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d", |
| 327 | 329 | vid, idm |
| 328 | 330 | ); |
| 329 | 331 | idv = db_last_insert_rowid(); |
| 330 | 332 | db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid); |
| 331 | 333 | zName = db_column_text(&q, 2); |
| 332 | - fossil_print("ADDED %s\n", zName); | |
| 334 | + zFullName = mprintf("%s%s", g.zLocalRoot, zName); | |
| 335 | + if( file_wd_isfile_or_link(zFullName) ){ | |
| 336 | + fossil_print("ADDED %s (overwrites an unmanaged file)\n", zName); | |
| 337 | + nOverwrite++; | |
| 338 | + }else{ | |
| 339 | + fossil_print("ADDED %s\n", zName); | |
| 340 | + } | |
| 341 | + fossil_free(zFullName); | |
| 333 | 342 | if( !nochangeFlag ){ |
| 334 | 343 | undo_save(zName); |
| 335 | 344 | vfile_to_disk(0, idm, 0, 0); |
| 336 | 345 | } |
| 337 | 346 | } |
| @@ -495,13 +504,18 @@ | ||
| 495 | 504 | db_finalize(&q); |
| 496 | 505 | |
| 497 | 506 | |
| 498 | 507 | /* Report on conflicts |
| 499 | 508 | */ |
| 500 | - if( nConflict && !nochangeFlag ){ | |
| 501 | - fossil_warning( | |
| 502 | - "WARNING: merge conflicts - see messages above for details.\n"); | |
| 509 | + if( !nochangeFlag ){ | |
| 510 | + if( nConflict ){ | |
| 511 | + fossil_print("WARNING: %d merge conflicts", nConflict); | |
| 512 | + } | |
| 513 | + if( nOverwrite ){ | |
| 514 | + fossil_warning("WARNING: %d unmanaged files where overwritten", | |
| 515 | + nOverwrite); | |
| 516 | + } | |
| 503 | 517 | } |
| 504 | 518 | |
| 505 | 519 | /* |
| 506 | 520 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 507 | 521 | */ |
| 508 | 522 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -73,10 +73,11 @@ | |
| 73 | int debugFlag; /* True if --debug is present */ |
| 74 | int nChng; /* Number of file name changes */ |
| 75 | int *aChng; /* An array of file name changes */ |
| 76 | int i; /* Loop counter */ |
| 77 | int nConflict = 0; /* Number of conflicts seen */ |
| 78 | int caseSensitive; /* True for case-sensitive filenames */ |
| 79 | Stmt q; |
| 80 | |
| 81 | |
| 82 | /* Notation: |
| @@ -319,19 +320,27 @@ | |
| 319 | while( db_step(&q)==SQLITE_ROW ){ |
| 320 | int idm = db_column_int(&q, 0); |
| 321 | int rowid = db_column_int(&q, 1); |
| 322 | int idv; |
| 323 | const char *zName; |
| 324 | db_multi_exec( |
| 325 | "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)" |
| 326 | " SELECT %d,3,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d", |
| 327 | vid, idm |
| 328 | ); |
| 329 | idv = db_last_insert_rowid(); |
| 330 | db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid); |
| 331 | zName = db_column_text(&q, 2); |
| 332 | fossil_print("ADDED %s\n", zName); |
| 333 | if( !nochangeFlag ){ |
| 334 | undo_save(zName); |
| 335 | vfile_to_disk(0, idm, 0, 0); |
| 336 | } |
| 337 | } |
| @@ -495,13 +504,18 @@ | |
| 495 | db_finalize(&q); |
| 496 | |
| 497 | |
| 498 | /* Report on conflicts |
| 499 | */ |
| 500 | if( nConflict && !nochangeFlag ){ |
| 501 | fossil_warning( |
| 502 | "WARNING: merge conflicts - see messages above for details.\n"); |
| 503 | } |
| 504 | |
| 505 | /* |
| 506 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 507 | */ |
| 508 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -73,10 +73,11 @@ | |
| 73 | int debugFlag; /* True if --debug is present */ |
| 74 | int nChng; /* Number of file name changes */ |
| 75 | int *aChng; /* An array of file name changes */ |
| 76 | int i; /* Loop counter */ |
| 77 | int nConflict = 0; /* Number of conflicts seen */ |
| 78 | int nOverwrite = 0; /* Number of unmanaged files overwritten */ |
| 79 | int caseSensitive; /* True for case-sensitive filenames */ |
| 80 | Stmt q; |
| 81 | |
| 82 | |
| 83 | /* Notation: |
| @@ -319,19 +320,27 @@ | |
| 320 | while( db_step(&q)==SQLITE_ROW ){ |
| 321 | int idm = db_column_int(&q, 0); |
| 322 | int rowid = db_column_int(&q, 1); |
| 323 | int idv; |
| 324 | const char *zName; |
| 325 | const char *zFullName; |
| 326 | db_multi_exec( |
| 327 | "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)" |
| 328 | " SELECT %d,3,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d", |
| 329 | vid, idm |
| 330 | ); |
| 331 | idv = db_last_insert_rowid(); |
| 332 | db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid); |
| 333 | zName = db_column_text(&q, 2); |
| 334 | zFullName = mprintf("%s%s", g.zLocalRoot, zName); |
| 335 | if( file_wd_isfile_or_link(zFullName) ){ |
| 336 | fossil_print("ADDED %s (overwrites an unmanaged file)\n", zName); |
| 337 | nOverwrite++; |
| 338 | }else{ |
| 339 | fossil_print("ADDED %s\n", zName); |
| 340 | } |
| 341 | fossil_free(zFullName); |
| 342 | if( !nochangeFlag ){ |
| 343 | undo_save(zName); |
| 344 | vfile_to_disk(0, idm, 0, 0); |
| 345 | } |
| 346 | } |
| @@ -495,13 +504,18 @@ | |
| 504 | db_finalize(&q); |
| 505 | |
| 506 | |
| 507 | /* Report on conflicts |
| 508 | */ |
| 509 | if( !nochangeFlag ){ |
| 510 | if( nConflict ){ |
| 511 | fossil_print("WARNING: %d merge conflicts", nConflict); |
| 512 | } |
| 513 | if( nOverwrite ){ |
| 514 | fossil_warning("WARNING: %d unmanaged files where overwritten", |
| 515 | nOverwrite); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | /* |
| 520 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 521 | */ |
| 522 |
+19
-8
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -96,10 +96,11 @@ | ||
| 96 | 96 | int debugFlag; /* --debug option */ |
| 97 | 97 | int nChng; /* Number of file renames */ |
| 98 | 98 | int *aChng; /* Array of file renames */ |
| 99 | 99 | int i; /* Loop counter */ |
| 100 | 100 | int nConflict = 0; /* Number of merge conflicts */ |
| 101 | + int nOverwrite = 0; /* Number of unmanaged files overwritten */ | |
| 101 | 102 | Stmt mtimeXfer; /* Statment to transfer mtimes */ |
| 102 | 103 | |
| 103 | 104 | if( !internalUpdate ){ |
| 104 | 105 | undo_capture_command_line(); |
| 105 | 106 | url_proxy_options(); |
| @@ -359,11 +360,16 @@ | ||
| 359 | 360 | */ |
| 360 | 361 | fossil_print("CONFLICT %s\n", zName); |
| 361 | 362 | nConflict++; |
| 362 | 363 | }else if( idt>0 && idv==0 ){ |
| 363 | 364 | /* File added in the target. */ |
| 364 | - fossil_print("ADD %s\n", zName); | |
| 365 | + if( file_wd_isfile_or_link(zFullPath) ){ | |
| 366 | + fossil_print("ADD %s (overwrites an unmanaged file)\n", zName); | |
| 367 | + nOverwrite++; | |
| 368 | + }else{ | |
| 369 | + fossil_print("ADD %s\n", zName); | |
| 370 | + } | |
| 365 | 371 | undo_save(zName); |
| 366 | 372 | if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); |
| 367 | 373 | }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){ |
| 368 | 374 | /* The file is unedited. Change it to the target version */ |
| 369 | 375 | undo_save(zName); |
| @@ -449,17 +455,22 @@ | ||
| 449 | 455 | fossil_print("--------------\n"); |
| 450 | 456 | show_common_info(tid, "updated-to:", 1, 0); |
| 451 | 457 | |
| 452 | 458 | /* Report on conflicts |
| 453 | 459 | */ |
| 454 | - if( nConflict && !nochangeFlag ){ | |
| 455 | - if( internalUpdate ){ | |
| 456 | - internalConflictCnt = nConflict; | |
| 457 | - }else{ | |
| 458 | - fossil_print( | |
| 459 | - "WARNING: %d merge conflicts - see messages above for details.\n", | |
| 460 | - nConflict); | |
| 460 | + if( !nochangeFlag ){ | |
| 461 | + if( nConflict ){ | |
| 462 | + if( internalUpdate ){ | |
| 463 | + internalConflictCnt = nConflict; | |
| 464 | + nConflict = 0; | |
| 465 | + }else{ | |
| 466 | + fossil_print("WARNING: %d merge conflicts", nConflict); | |
| 467 | + } | |
| 468 | + } | |
| 469 | + if( nOverwrite ){ | |
| 470 | + fossil_warning("WARNING: %d unmanaged files where overwritten", | |
| 471 | + nOverwrite); | |
| 461 | 472 | } |
| 462 | 473 | } |
| 463 | 474 | |
| 464 | 475 | /* |
| 465 | 476 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 466 | 477 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -96,10 +96,11 @@ | |
| 96 | int debugFlag; /* --debug option */ |
| 97 | int nChng; /* Number of file renames */ |
| 98 | int *aChng; /* Array of file renames */ |
| 99 | int i; /* Loop counter */ |
| 100 | int nConflict = 0; /* Number of merge conflicts */ |
| 101 | Stmt mtimeXfer; /* Statment to transfer mtimes */ |
| 102 | |
| 103 | if( !internalUpdate ){ |
| 104 | undo_capture_command_line(); |
| 105 | url_proxy_options(); |
| @@ -359,11 +360,16 @@ | |
| 359 | */ |
| 360 | fossil_print("CONFLICT %s\n", zName); |
| 361 | nConflict++; |
| 362 | }else if( idt>0 && idv==0 ){ |
| 363 | /* File added in the target. */ |
| 364 | fossil_print("ADD %s\n", zName); |
| 365 | undo_save(zName); |
| 366 | if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); |
| 367 | }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){ |
| 368 | /* The file is unedited. Change it to the target version */ |
| 369 | undo_save(zName); |
| @@ -449,17 +455,22 @@ | |
| 449 | fossil_print("--------------\n"); |
| 450 | show_common_info(tid, "updated-to:", 1, 0); |
| 451 | |
| 452 | /* Report on conflicts |
| 453 | */ |
| 454 | if( nConflict && !nochangeFlag ){ |
| 455 | if( internalUpdate ){ |
| 456 | internalConflictCnt = nConflict; |
| 457 | }else{ |
| 458 | fossil_print( |
| 459 | "WARNING: %d merge conflicts - see messages above for details.\n", |
| 460 | nConflict); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | /* |
| 465 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 466 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -96,10 +96,11 @@ | |
| 96 | int debugFlag; /* --debug option */ |
| 97 | int nChng; /* Number of file renames */ |
| 98 | int *aChng; /* Array of file renames */ |
| 99 | int i; /* Loop counter */ |
| 100 | int nConflict = 0; /* Number of merge conflicts */ |
| 101 | int nOverwrite = 0; /* Number of unmanaged files overwritten */ |
| 102 | Stmt mtimeXfer; /* Statment to transfer mtimes */ |
| 103 | |
| 104 | if( !internalUpdate ){ |
| 105 | undo_capture_command_line(); |
| 106 | url_proxy_options(); |
| @@ -359,11 +360,16 @@ | |
| 360 | */ |
| 361 | fossil_print("CONFLICT %s\n", zName); |
| 362 | nConflict++; |
| 363 | }else if( idt>0 && idv==0 ){ |
| 364 | /* File added in the target. */ |
| 365 | if( file_wd_isfile_or_link(zFullPath) ){ |
| 366 | fossil_print("ADD %s (overwrites an unmanaged file)\n", zName); |
| 367 | nOverwrite++; |
| 368 | }else{ |
| 369 | fossil_print("ADD %s\n", zName); |
| 370 | } |
| 371 | undo_save(zName); |
| 372 | if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); |
| 373 | }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){ |
| 374 | /* The file is unedited. Change it to the target version */ |
| 375 | undo_save(zName); |
| @@ -449,17 +455,22 @@ | |
| 455 | fossil_print("--------------\n"); |
| 456 | show_common_info(tid, "updated-to:", 1, 0); |
| 457 | |
| 458 | /* Report on conflicts |
| 459 | */ |
| 460 | if( !nochangeFlag ){ |
| 461 | if( nConflict ){ |
| 462 | if( internalUpdate ){ |
| 463 | internalConflictCnt = nConflict; |
| 464 | nConflict = 0; |
| 465 | }else{ |
| 466 | fossil_print("WARNING: %d merge conflicts", nConflict); |
| 467 | } |
| 468 | } |
| 469 | if( nOverwrite ){ |
| 470 | fossil_warning("WARNING: %d unmanaged files where overwritten", |
| 471 | nOverwrite); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | /* |
| 476 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 477 |