Fossil SCM
Add the --backout option to the "merge" command.
Commit
3f0393f555f0da35ca69cb7798af3d247a267f60
Parent
582570708805dc4…
1 file changed
+15
-6
+15
-6
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -30,32 +30,36 @@ | ||
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | /* |
| 33 | 33 | ** COMMAND: merge |
| 34 | 34 | ** |
| 35 | -** Usage: %fossil merge [--cherrypick] VERSION | |
| 35 | +** Usage: %fossil merge [--cherrypick] [--backout] VERSION | |
| 36 | 36 | ** |
| 37 | 37 | ** The argument is a version that should be merged into the current |
| 38 | 38 | ** checkout. All changes from VERSION back to the nearest common |
| 39 | -** ancestor are merged. Except, if the --cherrypick option is used | |
| 40 | -** only the changes associated with the single check-in VERSION are | |
| 41 | -** merged. | |
| 39 | +** ancestor are merged. Except, if either of the --cherrypick or | |
| 40 | +** --backout options are used only the changes associated with the | |
| 41 | +** single check-in VERSION are merged. The --backout option causes | |
| 42 | +** the changes associated with VERSION to be removed from the current | |
| 43 | +** checkout rather than added. | |
| 42 | 44 | ** |
| 43 | 45 | ** Only file content is merged. The result continues to use the |
| 44 | -** file and directory names from the current check-out even if those | |
| 46 | +** file and directory names from the current checkout even if those | |
| 45 | 47 | ** names might have been changed in the branch being merged in. |
| 46 | 48 | */ |
| 47 | 49 | void merge_cmd(void){ |
| 48 | 50 | int vid; /* Current version */ |
| 49 | 51 | int mid; /* Version we are merging against */ |
| 50 | 52 | int pid; /* The pivot version - most recent common ancestor */ |
| 51 | 53 | int detailFlag; /* True if the --detail option is present */ |
| 52 | 54 | int pickFlag; /* True if the --cherrypick option is present */ |
| 55 | + int backoutFlag; /* True if the --backout optioni is present */ | |
| 53 | 56 | Stmt q; |
| 54 | 57 | |
| 55 | 58 | detailFlag = find_option("detail",0,0)!=0; |
| 56 | 59 | pickFlag = find_option("cherrypick",0,0)!=0; |
| 60 | + backoutFlag = find_option("backout",0,0)!=0; | |
| 57 | 61 | if( g.argc!=3 ){ |
| 58 | 62 | usage("VERSION"); |
| 59 | 63 | } |
| 60 | 64 | db_must_be_within_tree(); |
| 61 | 65 | vid = db_lget_int("checkout", 0); |
| @@ -67,14 +71,19 @@ | ||
| 67 | 71 | fossil_fatal("not a version: %s", g.argv[2]); |
| 68 | 72 | } |
| 69 | 73 | if( mid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", mid) ){ |
| 70 | 74 | fossil_fatal("not a version: %s", g.argv[2]); |
| 71 | 75 | } |
| 72 | - if( pickFlag ){ | |
| 76 | + if( pickFlag || backoutFlag ){ | |
| 73 | 77 | pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid); |
| 74 | 78 | if( pid<=0 ){ |
| 75 | 79 | fossil_fatal("cannot find an ancestor for %s", g.argv[2]); |
| 80 | + } | |
| 81 | + if( backoutFlag ){ | |
| 82 | + int t = pid; | |
| 83 | + pid = mid; | |
| 84 | + mid = t; | |
| 76 | 85 | } |
| 77 | 86 | }else{ |
| 78 | 87 | pivot_set_primary(mid); |
| 79 | 88 | pivot_set_secondary(vid); |
| 80 | 89 | db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0"); |
| 81 | 90 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -30,32 +30,36 @@ | |
| 30 | |
| 31 | |
| 32 | /* |
| 33 | ** COMMAND: merge |
| 34 | ** |
| 35 | ** Usage: %fossil merge [--cherrypick] VERSION |
| 36 | ** |
| 37 | ** The argument is a version that should be merged into the current |
| 38 | ** checkout. All changes from VERSION back to the nearest common |
| 39 | ** ancestor are merged. Except, if the --cherrypick option is used |
| 40 | ** only the changes associated with the single check-in VERSION are |
| 41 | ** merged. |
| 42 | ** |
| 43 | ** Only file content is merged. The result continues to use the |
| 44 | ** file and directory names from the current check-out even if those |
| 45 | ** names might have been changed in the branch being merged in. |
| 46 | */ |
| 47 | void merge_cmd(void){ |
| 48 | int vid; /* Current version */ |
| 49 | int mid; /* Version we are merging against */ |
| 50 | int pid; /* The pivot version - most recent common ancestor */ |
| 51 | int detailFlag; /* True if the --detail option is present */ |
| 52 | int pickFlag; /* True if the --cherrypick option is present */ |
| 53 | Stmt q; |
| 54 | |
| 55 | detailFlag = find_option("detail",0,0)!=0; |
| 56 | pickFlag = find_option("cherrypick",0,0)!=0; |
| 57 | if( g.argc!=3 ){ |
| 58 | usage("VERSION"); |
| 59 | } |
| 60 | db_must_be_within_tree(); |
| 61 | vid = db_lget_int("checkout", 0); |
| @@ -67,14 +71,19 @@ | |
| 67 | fossil_fatal("not a version: %s", g.argv[2]); |
| 68 | } |
| 69 | if( mid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", mid) ){ |
| 70 | fossil_fatal("not a version: %s", g.argv[2]); |
| 71 | } |
| 72 | if( pickFlag ){ |
| 73 | pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid); |
| 74 | if( pid<=0 ){ |
| 75 | fossil_fatal("cannot find an ancestor for %s", g.argv[2]); |
| 76 | } |
| 77 | }else{ |
| 78 | pivot_set_primary(mid); |
| 79 | pivot_set_secondary(vid); |
| 80 | db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0"); |
| 81 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -30,32 +30,36 @@ | |
| 30 | |
| 31 | |
| 32 | /* |
| 33 | ** COMMAND: merge |
| 34 | ** |
| 35 | ** Usage: %fossil merge [--cherrypick] [--backout] VERSION |
| 36 | ** |
| 37 | ** The argument is a version that should be merged into the current |
| 38 | ** checkout. All changes from VERSION back to the nearest common |
| 39 | ** ancestor are merged. Except, if either of the --cherrypick or |
| 40 | ** --backout options are used only the changes associated with the |
| 41 | ** single check-in VERSION are merged. The --backout option causes |
| 42 | ** the changes associated with VERSION to be removed from the current |
| 43 | ** checkout rather than added. |
| 44 | ** |
| 45 | ** Only file content is merged. The result continues to use the |
| 46 | ** file and directory names from the current checkout even if those |
| 47 | ** names might have been changed in the branch being merged in. |
| 48 | */ |
| 49 | void merge_cmd(void){ |
| 50 | int vid; /* Current version */ |
| 51 | int mid; /* Version we are merging against */ |
| 52 | int pid; /* The pivot version - most recent common ancestor */ |
| 53 | int detailFlag; /* True if the --detail option is present */ |
| 54 | int pickFlag; /* True if the --cherrypick option is present */ |
| 55 | int backoutFlag; /* True if the --backout optioni is present */ |
| 56 | Stmt q; |
| 57 | |
| 58 | detailFlag = find_option("detail",0,0)!=0; |
| 59 | pickFlag = find_option("cherrypick",0,0)!=0; |
| 60 | backoutFlag = find_option("backout",0,0)!=0; |
| 61 | if( g.argc!=3 ){ |
| 62 | usage("VERSION"); |
| 63 | } |
| 64 | db_must_be_within_tree(); |
| 65 | vid = db_lget_int("checkout", 0); |
| @@ -67,14 +71,19 @@ | |
| 71 | fossil_fatal("not a version: %s", g.argv[2]); |
| 72 | } |
| 73 | if( mid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", mid) ){ |
| 74 | fossil_fatal("not a version: %s", g.argv[2]); |
| 75 | } |
| 76 | if( pickFlag || backoutFlag ){ |
| 77 | pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid); |
| 78 | if( pid<=0 ){ |
| 79 | fossil_fatal("cannot find an ancestor for %s", g.argv[2]); |
| 80 | } |
| 81 | if( backoutFlag ){ |
| 82 | int t = pid; |
| 83 | pid = mid; |
| 84 | mid = t; |
| 85 | } |
| 86 | }else{ |
| 87 | pivot_set_primary(mid); |
| 88 | pivot_set_secondary(vid); |
| 89 | db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0"); |
| 90 |