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.

drh 2011-10-17 01:12 trunk
Commit 39f979b08c4cf075a250e0d48d68144b2e0c3b0e
2 files changed +18 -4 +19 -8
+18 -4
--- src/merge.c
+++ src/merge.c
@@ -73,10 +73,11 @@
7373
int debugFlag; /* True if --debug is present */
7474
int nChng; /* Number of file name changes */
7575
int *aChng; /* An array of file name changes */
7676
int i; /* Loop counter */
7777
int nConflict = 0; /* Number of conflicts seen */
78
+ int nOverwrite = 0; /* Number of unmanaged files overwritten */
7879
int caseSensitive; /* True for case-sensitive filenames */
7980
Stmt q;
8081
8182
8283
/* Notation:
@@ -319,19 +320,27 @@
319320
while( db_step(&q)==SQLITE_ROW ){
320321
int idm = db_column_int(&q, 0);
321322
int rowid = db_column_int(&q, 1);
322323
int idv;
323324
const char *zName;
325
+ const char *zFullName;
324326
db_multi_exec(
325327
"INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)"
326328
" SELECT %d,3,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
327329
vid, idm
328330
);
329331
idv = db_last_insert_rowid();
330332
db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
331333
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);
333342
if( !nochangeFlag ){
334343
undo_save(zName);
335344
vfile_to_disk(0, idm, 0, 0);
336345
}
337346
}
@@ -495,13 +504,18 @@
495504
db_finalize(&q);
496505
497506
498507
/* Report on conflicts
499508
*/
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
+ }
503517
}
504518
505519
/*
506520
** Clean up the mid and pid VFILE entries. Then commit the changes.
507521
*/
508522
--- 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 @@
9696
int debugFlag; /* --debug option */
9797
int nChng; /* Number of file renames */
9898
int *aChng; /* Array of file renames */
9999
int i; /* Loop counter */
100100
int nConflict = 0; /* Number of merge conflicts */
101
+ int nOverwrite = 0; /* Number of unmanaged files overwritten */
101102
Stmt mtimeXfer; /* Statment to transfer mtimes */
102103
103104
if( !internalUpdate ){
104105
undo_capture_command_line();
105106
url_proxy_options();
@@ -359,11 +360,16 @@
359360
*/
360361
fossil_print("CONFLICT %s\n", zName);
361362
nConflict++;
362363
}else if( idt>0 && idv==0 ){
363364
/* 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
+ }
365371
undo_save(zName);
366372
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
367373
}else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
368374
/* The file is unedited. Change it to the target version */
369375
undo_save(zName);
@@ -449,17 +455,22 @@
449455
fossil_print("--------------\n");
450456
show_common_info(tid, "updated-to:", 1, 0);
451457
452458
/* Report on conflicts
453459
*/
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);
461472
}
462473
}
463474
464475
/*
465476
** Clean up the mid and pid VFILE entries. Then commit the changes.
466477
--- 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

Keyboard Shortcuts

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