Fossil SCM

Add the --baseline option to the "merge" command to facilitate merging of subsections of a branch.

drh 2011-01-20 18:54 trunk
Commit f7b4517ca7f51d0e4a3369381d57c4b89916da59
1 file changed +22 -10
+22 -10
--- src/merge.c
+++ src/merge.c
@@ -40,10 +40,15 @@
4040
** file and directory names from the current checkout even if those
4141
** names might have been changed in the branch being merged in.
4242
**
4343
** Other options:
4444
**
45
+** --baseline BASELINE Use BASELINE as the "pivot" of the merge instead
46
+** of the nearest common ancestor. This allows
47
+** a sequence of changes in a branch to be merged
48
+** without having to merge the entire branch.
49
+**
4550
** --detail Show additional details of the merge
4651
**
4752
** --binary GLOBPATTERN Treat files that match GLOBPATTERN as binary
4853
** and do not try to merge parallel changes. This
4954
** option overrides the "binary-glob" setting.
@@ -58,10 +63,11 @@
5863
int detailFlag; /* True if the --detail option is present */
5964
int pickFlag; /* True if the --cherrypick option is present */
6065
int backoutFlag; /* True if the --backout option is present */
6166
int nochangeFlag; /* True if the --nochange or -n option is present */
6267
const char *zBinGlob; /* The value of --binary */
68
+ const char *zPivot; /* The value of --baseline */
6369
int debugFlag; /* True if --debug is present */
6470
int nChng; /* Number of file name changes */
6571
int *aChng; /* An array of file name changes */
6672
int i; /* Loop counter */
6773
int nConflict = 0; /* Number of conflicts seen */
@@ -80,10 +86,11 @@
8086
pickFlag = find_option("cherrypick",0,0)!=0;
8187
backoutFlag = find_option("backout",0,0)!=0;
8288
debugFlag = find_option("debug",0,0)!=0;
8389
zBinGlob = find_option("binary",0,1);
8490
nochangeFlag = find_option("nochange","n",0)!=0;
91
+ zPivot = find_option("baseline",0,1);
8592
if( g.argc!=3 ){
8693
usage("VERSION");
8794
}
8895
db_must_be_within_tree();
8996
if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
@@ -90,26 +97,26 @@
9097
vid = db_lget_int("checkout", 0);
9198
if( vid==0 ){
9299
fossil_fatal("nothing is checked out");
93100
}
94101
mid = name_to_rid(g.argv[2]);
95
- if( mid==0 ){
102
+ if( mid==0 || !is_a_version(mid) ){
96103
fossil_fatal("not a version: %s", g.argv[2]);
97104
}
98
- if( !is_a_version(mid) ){
99
- fossil_fatal("not a version: %s", g.argv[2]);
100
- }
101
- if( pickFlag || backoutFlag ){
105
+ if( zPivot ){
106
+ pid = name_to_rid(zPivot);
107
+ if( pid==0 || !is_a_version(pid) ){
108
+ fossil_fatal("not a version: %s", zPivot);
109
+ }
110
+ if( pickFlag ){
111
+ fossil_fatal("incompatible options: --cherrypick & --baseline");
112
+ }
113
+ }else if( pickFlag || backoutFlag ){
102114
pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
103115
if( pid<=0 ){
104116
fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
105117
}
106
- if( backoutFlag ){
107
- int t = pid;
108
- pid = mid;
109
- mid = t;
110
- }
111118
}else{
112119
pivot_set_primary(mid);
113120
pivot_set_secondary(vid);
114121
db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0");
115122
while( db_step(&q)==SQLITE_ROW ){
@@ -119,10 +126,15 @@
119126
pid = pivot_find();
120127
if( pid<=0 ){
121128
fossil_fatal("cannot find a common ancestor between the current "
122129
"checkout and %s", g.argv[2]);
123130
}
131
+ }
132
+ if( backoutFlag ){
133
+ int t = pid;
134
+ pid = mid;
135
+ mid = t;
124136
}
125137
if( !is_a_version(pid) ){
126138
fossil_fatal("not a version: record #%d", pid);
127139
}
128140
vfile_check_signature(vid, 1, 0);
129141
--- src/merge.c
+++ src/merge.c
@@ -40,10 +40,15 @@
40 ** file and directory names from the current checkout even if those
41 ** names might have been changed in the branch being merged in.
42 **
43 ** Other options:
44 **
 
 
 
 
 
45 ** --detail Show additional details of the merge
46 **
47 ** --binary GLOBPATTERN Treat files that match GLOBPATTERN as binary
48 ** and do not try to merge parallel changes. This
49 ** option overrides the "binary-glob" setting.
@@ -58,10 +63,11 @@
58 int detailFlag; /* True if the --detail option is present */
59 int pickFlag; /* True if the --cherrypick option is present */
60 int backoutFlag; /* True if the --backout option is present */
61 int nochangeFlag; /* True if the --nochange or -n option is present */
62 const char *zBinGlob; /* The value of --binary */
 
63 int debugFlag; /* True if --debug is present */
64 int nChng; /* Number of file name changes */
65 int *aChng; /* An array of file name changes */
66 int i; /* Loop counter */
67 int nConflict = 0; /* Number of conflicts seen */
@@ -80,10 +86,11 @@
80 pickFlag = find_option("cherrypick",0,0)!=0;
81 backoutFlag = find_option("backout",0,0)!=0;
82 debugFlag = find_option("debug",0,0)!=0;
83 zBinGlob = find_option("binary",0,1);
84 nochangeFlag = find_option("nochange","n",0)!=0;
 
85 if( g.argc!=3 ){
86 usage("VERSION");
87 }
88 db_must_be_within_tree();
89 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
@@ -90,26 +97,26 @@
90 vid = db_lget_int("checkout", 0);
91 if( vid==0 ){
92 fossil_fatal("nothing is checked out");
93 }
94 mid = name_to_rid(g.argv[2]);
95 if( mid==0 ){
96 fossil_fatal("not a version: %s", g.argv[2]);
97 }
98 if( !is_a_version(mid) ){
99 fossil_fatal("not a version: %s", g.argv[2]);
100 }
101 if( pickFlag || backoutFlag ){
 
 
 
 
 
102 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
103 if( pid<=0 ){
104 fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
105 }
106 if( backoutFlag ){
107 int t = pid;
108 pid = mid;
109 mid = t;
110 }
111 }else{
112 pivot_set_primary(mid);
113 pivot_set_secondary(vid);
114 db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0");
115 while( db_step(&q)==SQLITE_ROW ){
@@ -119,10 +126,15 @@
119 pid = pivot_find();
120 if( pid<=0 ){
121 fossil_fatal("cannot find a common ancestor between the current "
122 "checkout and %s", g.argv[2]);
123 }
 
 
 
 
 
124 }
125 if( !is_a_version(pid) ){
126 fossil_fatal("not a version: record #%d", pid);
127 }
128 vfile_check_signature(vid, 1, 0);
129
--- src/merge.c
+++ src/merge.c
@@ -40,10 +40,15 @@
40 ** file and directory names from the current checkout even if those
41 ** names might have been changed in the branch being merged in.
42 **
43 ** Other options:
44 **
45 ** --baseline BASELINE Use BASELINE as the "pivot" of the merge instead
46 ** of the nearest common ancestor. This allows
47 ** a sequence of changes in a branch to be merged
48 ** without having to merge the entire branch.
49 **
50 ** --detail Show additional details of the merge
51 **
52 ** --binary GLOBPATTERN Treat files that match GLOBPATTERN as binary
53 ** and do not try to merge parallel changes. This
54 ** option overrides the "binary-glob" setting.
@@ -58,10 +63,11 @@
63 int detailFlag; /* True if the --detail option is present */
64 int pickFlag; /* True if the --cherrypick option is present */
65 int backoutFlag; /* True if the --backout option is present */
66 int nochangeFlag; /* True if the --nochange or -n option is present */
67 const char *zBinGlob; /* The value of --binary */
68 const char *zPivot; /* The value of --baseline */
69 int debugFlag; /* True if --debug is present */
70 int nChng; /* Number of file name changes */
71 int *aChng; /* An array of file name changes */
72 int i; /* Loop counter */
73 int nConflict = 0; /* Number of conflicts seen */
@@ -80,10 +86,11 @@
86 pickFlag = find_option("cherrypick",0,0)!=0;
87 backoutFlag = find_option("backout",0,0)!=0;
88 debugFlag = find_option("debug",0,0)!=0;
89 zBinGlob = find_option("binary",0,1);
90 nochangeFlag = find_option("nochange","n",0)!=0;
91 zPivot = find_option("baseline",0,1);
92 if( g.argc!=3 ){
93 usage("VERSION");
94 }
95 db_must_be_within_tree();
96 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
@@ -90,26 +97,26 @@
97 vid = db_lget_int("checkout", 0);
98 if( vid==0 ){
99 fossil_fatal("nothing is checked out");
100 }
101 mid = name_to_rid(g.argv[2]);
102 if( mid==0 || !is_a_version(mid) ){
103 fossil_fatal("not a version: %s", g.argv[2]);
104 }
105 if( zPivot ){
106 pid = name_to_rid(zPivot);
107 if( pid==0 || !is_a_version(pid) ){
108 fossil_fatal("not a version: %s", zPivot);
109 }
110 if( pickFlag ){
111 fossil_fatal("incompatible options: --cherrypick & --baseline");
112 }
113 }else if( pickFlag || backoutFlag ){
114 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
115 if( pid<=0 ){
116 fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
117 }
 
 
 
 
 
118 }else{
119 pivot_set_primary(mid);
120 pivot_set_secondary(vid);
121 db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0");
122 while( db_step(&q)==SQLITE_ROW ){
@@ -119,10 +126,15 @@
126 pid = pivot_find();
127 if( pid<=0 ){
128 fossil_fatal("cannot find a common ancestor between the current "
129 "checkout and %s", g.argv[2]);
130 }
131 }
132 if( backoutFlag ){
133 int t = pid;
134 pid = mid;
135 mid = t;
136 }
137 if( !is_a_version(pid) ){
138 fossil_fatal("not a version: record #%d", pid);
139 }
140 vfile_check_signature(vid, 1, 0);
141

Keyboard Shortcuts

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