Fossil SCM

Add the --nochange and -n options to the "merge" command.

drh 2010-12-08 20:44 trunk
Commit 000af3234f32afd31dbfc448a25100931f847861
1 file changed +19 -10
+19 -10
--- src/merge.c
+++ src/merge.c
@@ -45,25 +45,30 @@
4545
** --detail Show additional details of the merge
4646
**
4747
** --binary GLOBPATTERN Treat files that match GLOBPATTERN as binary
4848
** and do not try to merge parallel changes. This
4949
** option overrides the "binary-glob" setting.
50
+**
51
+** --nochange | -n Dryrun: do not actually make any changes; just
52
+** show what would have happened.
5053
*/
5154
void merge_cmd(void){
5255
int vid; /* Current version */
5356
int mid; /* Version we are merging against */
5457
int pid; /* The pivot version - most recent common ancestor */
5558
int detailFlag; /* True if the --detail option is present */
5659
int pickFlag; /* True if the --cherrypick option is present */
57
- int backoutFlag; /* True if the --backout optioni is present */
60
+ int backoutFlag; /* True if the --backout option is present */
61
+ int nochangeFlag; /* True if the --nochange or -n option is present */
5862
const char *zBinGlob; /* The value of --binary */
5963
Stmt q;
6064
6165
detailFlag = find_option("detail",0,0)!=0;
6266
pickFlag = find_option("cherrypick",0,0)!=0;
6367
backoutFlag = find_option("backout",0,0)!=0;
6468
zBinGlob = find_option("binary",0,1);
69
+ nochangeFlag = find_option("nochange","n",0)!=0;
6570
if( g.argc!=3 ){
6671
usage("VERSION");
6772
}
6873
db_must_be_within_tree();
6974
if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
@@ -210,12 +215,14 @@
210215
);
211216
idv = db_last_insert_rowid();
212217
db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
213218
zName = db_column_text(&q, 2);
214219
printf("ADDED %s\n", zName);
215
- undo_save(zName);
216
- vfile_to_disk(0, idm, 0, 0);
220
+ if( !nochangeFlag ){
221
+ undo_save(zName);
222
+ vfile_to_disk(0, idm, 0, 0);
223
+ }
217224
}
218225
db_finalize(&q);
219226
220227
/*
221228
** Find files that have changed from pid->mid but not pid->vid.
@@ -230,15 +237,17 @@
230237
int idv = db_column_int(&q, 0);
231238
int ridm = db_column_int(&q, 1);
232239
char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idv);
233240
/* Copy content from idm over into idv. Overwrite idv. */
234241
printf("UPDATE %s\n", zName);
235
- undo_save(zName);
236
- db_multi_exec(
237
- "UPDATE vfile SET mrid=%d, chnged=2 WHERE id=%d", ridm, idv
238
- );
239
- vfile_to_disk(0, idv, 0, 0);
242
+ if( !nochangeFlag ){
243
+ undo_save(zName);
244
+ db_multi_exec(
245
+ "UPDATE vfile SET mrid=%d, chnged=2 WHERE id=%d", ridm, idv
246
+ );
247
+ vfile_to_disk(0, idv, 0, 0);
248
+ }
240249
free(zName);
241250
}
242251
db_finalize(&q);
243252
244253
/*
@@ -277,11 +286,11 @@
277286
blob_zero(&r);
278287
}else{
279288
rc = blob_merge(&p, &m, &v, &r);
280289
}
281290
if( rc>=0 ){
282
- blob_write_to_file(&r, zFullPath);
291
+ if( !nochangeFlag ) blob_write_to_file(&r, zFullPath);
283292
if( rc>0 ){
284293
printf("***** %d merge conflicts in %s\n", rc, zName);
285294
}
286295
}else{
287296
printf("***** Cannot merge binary file %s\n", zName);
@@ -322,7 +331,7 @@
322331
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
323332
if( !pickFlag ){
324333
db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
325334
}
326335
undo_finish();
327
- db_end_transaction(0);
336
+ db_end_transaction(nochangeFlag);
328337
}
329338
--- src/merge.c
+++ src/merge.c
@@ -45,25 +45,30 @@
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.
 
 
 
50 */
51 void merge_cmd(void){
52 int vid; /* Current version */
53 int mid; /* Version we are merging against */
54 int pid; /* The pivot version - most recent common ancestor */
55 int detailFlag; /* True if the --detail option is present */
56 int pickFlag; /* True if the --cherrypick option is present */
57 int backoutFlag; /* True if the --backout optioni is present */
 
58 const char *zBinGlob; /* The value of --binary */
59 Stmt q;
60
61 detailFlag = find_option("detail",0,0)!=0;
62 pickFlag = find_option("cherrypick",0,0)!=0;
63 backoutFlag = find_option("backout",0,0)!=0;
64 zBinGlob = find_option("binary",0,1);
 
65 if( g.argc!=3 ){
66 usage("VERSION");
67 }
68 db_must_be_within_tree();
69 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
@@ -210,12 +215,14 @@
210 );
211 idv = db_last_insert_rowid();
212 db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
213 zName = db_column_text(&q, 2);
214 printf("ADDED %s\n", zName);
215 undo_save(zName);
216 vfile_to_disk(0, idm, 0, 0);
 
 
217 }
218 db_finalize(&q);
219
220 /*
221 ** Find files that have changed from pid->mid but not pid->vid.
@@ -230,15 +237,17 @@
230 int idv = db_column_int(&q, 0);
231 int ridm = db_column_int(&q, 1);
232 char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idv);
233 /* Copy content from idm over into idv. Overwrite idv. */
234 printf("UPDATE %s\n", zName);
235 undo_save(zName);
236 db_multi_exec(
237 "UPDATE vfile SET mrid=%d, chnged=2 WHERE id=%d", ridm, idv
238 );
239 vfile_to_disk(0, idv, 0, 0);
 
 
240 free(zName);
241 }
242 db_finalize(&q);
243
244 /*
@@ -277,11 +286,11 @@
277 blob_zero(&r);
278 }else{
279 rc = blob_merge(&p, &m, &v, &r);
280 }
281 if( rc>=0 ){
282 blob_write_to_file(&r, zFullPath);
283 if( rc>0 ){
284 printf("***** %d merge conflicts in %s\n", rc, zName);
285 }
286 }else{
287 printf("***** Cannot merge binary file %s\n", zName);
@@ -322,7 +331,7 @@
322 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
323 if( !pickFlag ){
324 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
325 }
326 undo_finish();
327 db_end_transaction(0);
328 }
329
--- src/merge.c
+++ src/merge.c
@@ -45,25 +45,30 @@
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.
50 **
51 ** --nochange | -n Dryrun: do not actually make any changes; just
52 ** show what would have happened.
53 */
54 void merge_cmd(void){
55 int vid; /* Current version */
56 int mid; /* Version we are merging against */
57 int pid; /* The pivot version - most recent common ancestor */
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 Stmt q;
64
65 detailFlag = find_option("detail",0,0)!=0;
66 pickFlag = find_option("cherrypick",0,0)!=0;
67 backoutFlag = find_option("backout",0,0)!=0;
68 zBinGlob = find_option("binary",0,1);
69 nochangeFlag = find_option("nochange","n",0)!=0;
70 if( g.argc!=3 ){
71 usage("VERSION");
72 }
73 db_must_be_within_tree();
74 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
@@ -210,12 +215,14 @@
215 );
216 idv = db_last_insert_rowid();
217 db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
218 zName = db_column_text(&q, 2);
219 printf("ADDED %s\n", zName);
220 if( !nochangeFlag ){
221 undo_save(zName);
222 vfile_to_disk(0, idm, 0, 0);
223 }
224 }
225 db_finalize(&q);
226
227 /*
228 ** Find files that have changed from pid->mid but not pid->vid.
@@ -230,15 +237,17 @@
237 int idv = db_column_int(&q, 0);
238 int ridm = db_column_int(&q, 1);
239 char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idv);
240 /* Copy content from idm over into idv. Overwrite idv. */
241 printf("UPDATE %s\n", zName);
242 if( !nochangeFlag ){
243 undo_save(zName);
244 db_multi_exec(
245 "UPDATE vfile SET mrid=%d, chnged=2 WHERE id=%d", ridm, idv
246 );
247 vfile_to_disk(0, idv, 0, 0);
248 }
249 free(zName);
250 }
251 db_finalize(&q);
252
253 /*
@@ -277,11 +286,11 @@
286 blob_zero(&r);
287 }else{
288 rc = blob_merge(&p, &m, &v, &r);
289 }
290 if( rc>=0 ){
291 if( !nochangeFlag ) blob_write_to_file(&r, zFullPath);
292 if( rc>0 ){
293 printf("***** %d merge conflicts in %s\n", rc, zName);
294 }
295 }else{
296 printf("***** Cannot merge binary file %s\n", zName);
@@ -322,7 +331,7 @@
331 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
332 if( !pickFlag ){
333 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
334 }
335 undo_finish();
336 db_end_transaction(nochangeFlag);
337 }
338

Keyboard Shortcuts

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