Fossil SCM
Refactor revert command SQL slightly.
Commit
e66a12ec4bfa24bcc4fd096be6f08fbd6d921c78
Parent
23d3113bb1518f5…
1 file changed
+10
-12
+10
-12
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -717,16 +717,12 @@ | ||
| 717 | 717 | db_multi_exec( |
| 718 | 718 | "REPLACE INTO torevert VALUES(%B);" |
| 719 | 719 | "INSERT OR IGNORE INTO torevert" |
| 720 | 720 | " SELECT pathname" |
| 721 | 721 | " FROM vfile" |
| 722 | - " WHERE origname IN(%B)" | |
| 723 | - " UNION ALL" | |
| 724 | - " SELECT origname" | |
| 725 | - " FROM vfile" | |
| 726 | - " WHERE pathname IN(%B) AND origname IS NOT NULL;", | |
| 727 | - &fname, &fname, &fname | |
| 722 | + " WHERE origname=%B;", | |
| 723 | + &fname, &fname | |
| 728 | 724 | ); |
| 729 | 725 | blob_reset(&fname); |
| 730 | 726 | } |
| 731 | 727 | }else{ |
| 732 | 728 | int vid; |
| @@ -735,17 +731,19 @@ | ||
| 735 | 731 | db_multi_exec( |
| 736 | 732 | "DELETE FROM vmerge;" |
| 737 | 733 | "INSERT OR IGNORE INTO torevert " |
| 738 | 734 | " SELECT pathname" |
| 739 | 735 | " FROM vfile " |
| 740 | - " WHERE chnged OR deleted OR rid=0 OR pathname!=origname " | |
| 741 | - " UNION ALL " | |
| 742 | - " SELECT origname" | |
| 743 | - " FROM vfile" | |
| 744 | - " WHERE origname!=pathname;" | |
| 736 | + " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;" | |
| 745 | 737 | ); |
| 746 | 738 | } |
| 739 | + db_multi_exec( | |
| 740 | + "INSERT OR IGNORE INTO torevert" | |
| 741 | + " SELECT origname" | |
| 742 | + " FROM vfile" | |
| 743 | + " WHERE origname!=pathname AND pathname IN (SELECT name FROM torevert);" | |
| 744 | + ); | |
| 747 | 745 | blob_zero(&record); |
| 748 | 746 | db_prepare(&q, "SELECT name FROM torevert"); |
| 749 | 747 | if( zRevision==0 ){ |
| 750 | 748 | int vid = db_lget_int("checkout", 0); |
| 751 | 749 | zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); |
| @@ -768,11 +766,11 @@ | ||
| 768 | 766 | fossil_print("DELETE: %s\n", zFile); |
| 769 | 767 | } |
| 770 | 768 | db_multi_exec( |
| 771 | 769 | "UPDATE vfile" |
| 772 | 770 | " SET pathname=origname, origname=NULL" |
| 773 | - " WHERE pathname=%Q AND origname!=pathname AND origname IS NOT NULL;" | |
| 771 | + " WHERE pathname=%Q AND origname!=pathname;" | |
| 774 | 772 | "DELETE FROM vfile WHERE pathname=%Q", |
| 775 | 773 | zFile, zFile |
| 776 | 774 | ); |
| 777 | 775 | }else{ |
| 778 | 776 | sqlite3_int64 mtime; |
| 779 | 777 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -717,16 +717,12 @@ | |
| 717 | db_multi_exec( |
| 718 | "REPLACE INTO torevert VALUES(%B);" |
| 719 | "INSERT OR IGNORE INTO torevert" |
| 720 | " SELECT pathname" |
| 721 | " FROM vfile" |
| 722 | " WHERE origname IN(%B)" |
| 723 | " UNION ALL" |
| 724 | " SELECT origname" |
| 725 | " FROM vfile" |
| 726 | " WHERE pathname IN(%B) AND origname IS NOT NULL;", |
| 727 | &fname, &fname, &fname |
| 728 | ); |
| 729 | blob_reset(&fname); |
| 730 | } |
| 731 | }else{ |
| 732 | int vid; |
| @@ -735,17 +731,19 @@ | |
| 735 | db_multi_exec( |
| 736 | "DELETE FROM vmerge;" |
| 737 | "INSERT OR IGNORE INTO torevert " |
| 738 | " SELECT pathname" |
| 739 | " FROM vfile " |
| 740 | " WHERE chnged OR deleted OR rid=0 OR pathname!=origname " |
| 741 | " UNION ALL " |
| 742 | " SELECT origname" |
| 743 | " FROM vfile" |
| 744 | " WHERE origname!=pathname;" |
| 745 | ); |
| 746 | } |
| 747 | blob_zero(&record); |
| 748 | db_prepare(&q, "SELECT name FROM torevert"); |
| 749 | if( zRevision==0 ){ |
| 750 | int vid = db_lget_int("checkout", 0); |
| 751 | zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); |
| @@ -768,11 +766,11 @@ | |
| 768 | fossil_print("DELETE: %s\n", zFile); |
| 769 | } |
| 770 | db_multi_exec( |
| 771 | "UPDATE vfile" |
| 772 | " SET pathname=origname, origname=NULL" |
| 773 | " WHERE pathname=%Q AND origname!=pathname AND origname IS NOT NULL;" |
| 774 | "DELETE FROM vfile WHERE pathname=%Q", |
| 775 | zFile, zFile |
| 776 | ); |
| 777 | }else{ |
| 778 | sqlite3_int64 mtime; |
| 779 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -717,16 +717,12 @@ | |
| 717 | db_multi_exec( |
| 718 | "REPLACE INTO torevert VALUES(%B);" |
| 719 | "INSERT OR IGNORE INTO torevert" |
| 720 | " SELECT pathname" |
| 721 | " FROM vfile" |
| 722 | " WHERE origname=%B;", |
| 723 | &fname, &fname |
| 724 | ); |
| 725 | blob_reset(&fname); |
| 726 | } |
| 727 | }else{ |
| 728 | int vid; |
| @@ -735,17 +731,19 @@ | |
| 731 | db_multi_exec( |
| 732 | "DELETE FROM vmerge;" |
| 733 | "INSERT OR IGNORE INTO torevert " |
| 734 | " SELECT pathname" |
| 735 | " FROM vfile " |
| 736 | " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;" |
| 737 | ); |
| 738 | } |
| 739 | db_multi_exec( |
| 740 | "INSERT OR IGNORE INTO torevert" |
| 741 | " SELECT origname" |
| 742 | " FROM vfile" |
| 743 | " WHERE origname!=pathname AND pathname IN (SELECT name FROM torevert);" |
| 744 | ); |
| 745 | blob_zero(&record); |
| 746 | db_prepare(&q, "SELECT name FROM torevert"); |
| 747 | if( zRevision==0 ){ |
| 748 | int vid = db_lget_int("checkout", 0); |
| 749 | zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); |
| @@ -768,11 +766,11 @@ | |
| 766 | fossil_print("DELETE: %s\n", zFile); |
| 767 | } |
| 768 | db_multi_exec( |
| 769 | "UPDATE vfile" |
| 770 | " SET pathname=origname, origname=NULL" |
| 771 | " WHERE pathname=%Q AND origname!=pathname;" |
| 772 | "DELETE FROM vfile WHERE pathname=%Q", |
| 773 | zFile, zFile |
| 774 | ); |
| 775 | }else{ |
| 776 | sqlite3_int64 mtime; |
| 777 |