Fossil SCM

Fix "fossil revert" so that it works on files that have been renamed.

drh 2013-01-07 15:03 trunk
Commit 48798b27194107cec0bb4df97e79e560c882a9c6
1 file changed +10 -5
+10 -5
--- src/update.c
+++ src/update.c
@@ -715,14 +715,18 @@
715715
int vid;
716716
vid = db_lget_int("checkout", 0);
717717
vfile_check_signature(vid, 0);
718718
db_multi_exec(
719719
"DELETE FROM vmerge;"
720
- "INSERT INTO torevert "
721
- "SELECT pathname"
722
- " FROM vfile "
723
- " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;"
720
+ "INSERT OR IGNORE INTO torevert "
721
+ " SELECT pathname"
722
+ " FROM vfile "
723
+ " WHERE chnged OR deleted OR rid=0 OR pathname!=origname "
724
+ " UNION ALL "
725
+ " SELECT origname"
726
+ " FROM vfile"
727
+ " WHERE origname!=pathname;"
724728
);
725729
}
726730
blob_zero(&record);
727731
db_prepare(&q, "SELECT name FROM torevert");
728732
if( zRevision==0 ){
@@ -736,11 +740,12 @@
736740
zFile = db_column_text(&q, 0);
737741
zFull = mprintf("%/%/", g.zLocalRoot, zFile);
738742
errCode = historical_version_of_file(zRevision, zFile, &record,
739743
&isLink, &isExe, 0, 2);
740744
if( errCode==2 ){
741
- if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){
745
+ if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q OR origname=%Q",
746
+ zFile, zFile)==0 ){
742747
fossil_print("UNMANAGE: %s\n", zFile);
743748
}else{
744749
undo_save(zFile);
745750
file_delete(zFull);
746751
fossil_print("DELETE: %s\n", zFile);
747752
--- src/update.c
+++ src/update.c
@@ -715,14 +715,18 @@
715 int vid;
716 vid = db_lget_int("checkout", 0);
717 vfile_check_signature(vid, 0);
718 db_multi_exec(
719 "DELETE FROM vmerge;"
720 "INSERT INTO torevert "
721 "SELECT pathname"
722 " FROM vfile "
723 " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;"
 
 
 
 
724 );
725 }
726 blob_zero(&record);
727 db_prepare(&q, "SELECT name FROM torevert");
728 if( zRevision==0 ){
@@ -736,11 +740,12 @@
736 zFile = db_column_text(&q, 0);
737 zFull = mprintf("%/%/", g.zLocalRoot, zFile);
738 errCode = historical_version_of_file(zRevision, zFile, &record,
739 &isLink, &isExe, 0, 2);
740 if( errCode==2 ){
741 if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){
 
742 fossil_print("UNMANAGE: %s\n", zFile);
743 }else{
744 undo_save(zFile);
745 file_delete(zFull);
746 fossil_print("DELETE: %s\n", zFile);
747
--- src/update.c
+++ src/update.c
@@ -715,14 +715,18 @@
715 int vid;
716 vid = db_lget_int("checkout", 0);
717 vfile_check_signature(vid, 0);
718 db_multi_exec(
719 "DELETE FROM vmerge;"
720 "INSERT OR IGNORE INTO torevert "
721 " SELECT pathname"
722 " FROM vfile "
723 " WHERE chnged OR deleted OR rid=0 OR pathname!=origname "
724 " UNION ALL "
725 " SELECT origname"
726 " FROM vfile"
727 " WHERE origname!=pathname;"
728 );
729 }
730 blob_zero(&record);
731 db_prepare(&q, "SELECT name FROM torevert");
732 if( zRevision==0 ){
@@ -736,11 +740,12 @@
740 zFile = db_column_text(&q, 0);
741 zFull = mprintf("%/%/", g.zLocalRoot, zFile);
742 errCode = historical_version_of_file(zRevision, zFile, &record,
743 &isLink, &isExe, 0, 2);
744 if( errCode==2 ){
745 if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q OR origname=%Q",
746 zFile, zFile)==0 ){
747 fossil_print("UNMANAGE: %s\n", zFile);
748 }else{
749 undo_save(zFile);
750 file_delete(zFull);
751 fossil_print("DELETE: %s\n", zFile);
752

Keyboard Shortcuts

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