Fossil SCM

Add the --backout option to the "merge" command.

drh 2010-03-06 15:49 trunk
Commit 3f0393f555f0da35ca69cb7798af3d247a267f60
1 file changed +15 -6
+15 -6
--- src/merge.c
+++ src/merge.c
@@ -30,32 +30,36 @@
3030
3131
3232
/*
3333
** COMMAND: merge
3434
**
35
-** Usage: %fossil merge [--cherrypick] VERSION
35
+** Usage: %fossil merge [--cherrypick] [--backout] VERSION
3636
**
3737
** The argument is a version that should be merged into the current
3838
** 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.
4244
**
4345
** 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
4547
** names might have been changed in the branch being merged in.
4648
*/
4749
void merge_cmd(void){
4850
int vid; /* Current version */
4951
int mid; /* Version we are merging against */
5052
int pid; /* The pivot version - most recent common ancestor */
5153
int detailFlag; /* True if the --detail option is present */
5254
int pickFlag; /* True if the --cherrypick option is present */
55
+ int backoutFlag; /* True if the --backout optioni is present */
5356
Stmt q;
5457
5558
detailFlag = find_option("detail",0,0)!=0;
5659
pickFlag = find_option("cherrypick",0,0)!=0;
60
+ backoutFlag = find_option("backout",0,0)!=0;
5761
if( g.argc!=3 ){
5862
usage("VERSION");
5963
}
6064
db_must_be_within_tree();
6165
vid = db_lget_int("checkout", 0);
@@ -67,14 +71,19 @@
6771
fossil_fatal("not a version: %s", g.argv[2]);
6872
}
6973
if( mid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", mid) ){
7074
fossil_fatal("not a version: %s", g.argv[2]);
7175
}
72
- if( pickFlag ){
76
+ if( pickFlag || backoutFlag ){
7377
pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
7478
if( pid<=0 ){
7579
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;
7685
}
7786
}else{
7887
pivot_set_primary(mid);
7988
pivot_set_secondary(vid);
8089
db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0");
8190
--- 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

Keyboard Shortcuts

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