Fossil SCM

Fix the "revert" command so that it distinguishes between files that were added versus files imported by merge. Added files are not unlinked. Ticket [baf9b6b11e08c1].

drh 2011-02-28 13:26 UTC exe-permission-fix
Commit 157eed29f4a93afaab20fe37a69f1042a398b231
1 file changed +8 -4
+8 -4
--- src/update.c
+++ src/update.c
@@ -569,13 +569,17 @@
569569
char *zFull;
570570
zFile = db_column_text(&q, 0);
571571
zFull = mprintf("%/%/", g.zLocalRoot, zFile);
572572
errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
573573
if( errCode==2 ){
574
- undo_save(zFile);
575
- unlink(zFull);
576
- printf("DELETE: %s\n", zFile);
574
+ if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){
575
+ printf("UNMANAGE: %s\n", zFile);
576
+ }else{
577
+ undo_save(zFile);
578
+ unlink(zFull);
579
+ printf("DELETE: %s\n", zFile);
580
+ }
577581
db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
578582
}else{
579583
sqlite3_int64 mtime;
580584
undo_save(zFile);
581585
blob_write_to_file(&record, zFull);
@@ -582,11 +586,11 @@
582586
file_setexe(zFull, isExe);
583587
printf("REVERTED: %s\n", zFile);
584588
mtime = file_mtime(zFull);
585589
db_multi_exec(
586590
"UPDATE vfile"
587
- " SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
591
+ " SET mtime=%lld, chnged=0, deleted=0, isexe=%d, mrid=rid,"
588592
" pathname=coalesce(origname,pathname), origname=NULL"
589593
" WHERE pathname=%Q",
590594
mtime, isExe, zFile
591595
);
592596
}
593597
--- src/update.c
+++ src/update.c
@@ -569,13 +569,17 @@
569 char *zFull;
570 zFile = db_column_text(&q, 0);
571 zFull = mprintf("%/%/", g.zLocalRoot, zFile);
572 errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
573 if( errCode==2 ){
574 undo_save(zFile);
575 unlink(zFull);
576 printf("DELETE: %s\n", zFile);
 
 
 
 
577 db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
578 }else{
579 sqlite3_int64 mtime;
580 undo_save(zFile);
581 blob_write_to_file(&record, zFull);
@@ -582,11 +586,11 @@
582 file_setexe(zFull, isExe);
583 printf("REVERTED: %s\n", zFile);
584 mtime = file_mtime(zFull);
585 db_multi_exec(
586 "UPDATE vfile"
587 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
588 " pathname=coalesce(origname,pathname), origname=NULL"
589 " WHERE pathname=%Q",
590 mtime, isExe, zFile
591 );
592 }
593
--- src/update.c
+++ src/update.c
@@ -569,13 +569,17 @@
569 char *zFull;
570 zFile = db_column_text(&q, 0);
571 zFull = mprintf("%/%/", g.zLocalRoot, zFile);
572 errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
573 if( errCode==2 ){
574 if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){
575 printf("UNMANAGE: %s\n", zFile);
576 }else{
577 undo_save(zFile);
578 unlink(zFull);
579 printf("DELETE: %s\n", zFile);
580 }
581 db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
582 }else{
583 sqlite3_int64 mtime;
584 undo_save(zFile);
585 blob_write_to_file(&record, zFull);
@@ -582,11 +586,11 @@
586 file_setexe(zFull, isExe);
587 printf("REVERTED: %s\n", zFile);
588 mtime = file_mtime(zFull);
589 db_multi_exec(
590 "UPDATE vfile"
591 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d, mrid=rid,"
592 " pathname=coalesce(origname,pathname), origname=NULL"
593 " WHERE pathname=%Q",
594 mtime, isExe, zFile
595 );
596 }
597

Keyboard Shortcuts

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