Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the --nochange and -n options to the "merge" command. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
000af3234f32afd31dbfc448a2510093 |
| User & Date: | drh 2010-12-08 20:44:45.000 |
Context
|
2010-12-08
| ||
| 21:00 | Add the --sha1sum option to the "status" and "changes" commands to force a detailed (but slow) SHA1 checksum verification that files have not changed. check-in: e154a4386b user: drh tags: trunk | |
| 20:44 | Add the --nochange and -n options to the "merge" command. check-in: 000af3234f user: drh tags: trunk | |
| 03:31 | Ignore unfinalized statements when shutting down the SQLite command-line shell. Ticket [891cd78969e03ec3009]. check-in: 31f5b295fa user: drh tags: trunk | |
Changes
Changes to src/merge.c.
| ︙ | ︙ | |||
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
** Other options:
**
** --detail Show additional details of the merge
**
** --binary GLOBPATTERN Treat files that match GLOBPATTERN as binary
** and do not try to merge parallel changes. This
** option overrides the "binary-glob" setting.
*/
void merge_cmd(void){
int vid; /* Current version */
int mid; /* Version we are merging against */
int pid; /* The pivot version - most recent common ancestor */
int detailFlag; /* True if the --detail option is present */
int pickFlag; /* True if the --cherrypick option is present */
| > > > | > > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
** Other options:
**
** --detail Show additional details of the merge
**
** --binary GLOBPATTERN Treat files that match GLOBPATTERN as binary
** and do not try to merge parallel changes. This
** option overrides the "binary-glob" setting.
**
** --nochange | -n Dryrun: do not actually make any changes; just
** show what would have happened.
*/
void merge_cmd(void){
int vid; /* Current version */
int mid; /* Version we are merging against */
int pid; /* The pivot version - most recent common ancestor */
int detailFlag; /* True if the --detail option is present */
int pickFlag; /* True if the --cherrypick option is present */
int backoutFlag; /* True if the --backout option is present */
int nochangeFlag; /* True if the --nochange or -n option is present */
const char *zBinGlob; /* The value of --binary */
Stmt q;
detailFlag = find_option("detail",0,0)!=0;
pickFlag = find_option("cherrypick",0,0)!=0;
backoutFlag = find_option("backout",0,0)!=0;
zBinGlob = find_option("binary",0,1);
nochangeFlag = find_option("nochange","n",0)!=0;
if( g.argc!=3 ){
usage("VERSION");
}
db_must_be_within_tree();
if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
vid = db_lget_int("checkout", 0);
if( vid==0 ){
|
| ︙ | ︙ | |||
208 209 210 211 212 213 214 |
" SELECT %d,3,0,rid,mrid,pathname FROM vfile WHERE id=%d",
vid, idm
);
idv = db_last_insert_rowid();
db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
zName = db_column_text(&q, 2);
printf("ADDED %s\n", zName);
| > | | > > | | | | | > | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
" SELECT %d,3,0,rid,mrid,pathname FROM vfile WHERE id=%d",
vid, idm
);
idv = db_last_insert_rowid();
db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
zName = db_column_text(&q, 2);
printf("ADDED %s\n", zName);
if( !nochangeFlag ){
undo_save(zName);
vfile_to_disk(0, idm, 0, 0);
}
}
db_finalize(&q);
/*
** Find files that have changed from pid->mid but not pid->vid.
** Copy the mid content over into vid.
*/
db_prepare(&q,
"SELECT idv, ridm FROM fv"
" WHERE idp>0 AND idv>0 AND idm>0"
" AND ridm!=ridp AND ridv=ridp AND NOT chnged"
);
while( db_step(&q)==SQLITE_ROW ){
int idv = db_column_int(&q, 0);
int ridm = db_column_int(&q, 1);
char *zName = db_text(0, "SELECT pathname FROM vfile WHERE id=%d", idv);
/* Copy content from idm over into idv. Overwrite idv. */
printf("UPDATE %s\n", zName);
if( !nochangeFlag ){
undo_save(zName);
db_multi_exec(
"UPDATE vfile SET mrid=%d, chnged=2 WHERE id=%d", ridm, idv
);
vfile_to_disk(0, idv, 0, 0);
}
free(zName);
}
db_finalize(&q);
/*
** Do a three-way merge on files that have changes pid->mid and pid->vid
*/
|
| ︙ | ︙ | |||
275 276 277 278 279 280 281 |
if( isBinary ){
rc = -1;
blob_zero(&r);
}else{
rc = blob_merge(&p, &m, &v, &r);
}
if( rc>=0 ){
| | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
if( isBinary ){
rc = -1;
blob_zero(&r);
}else{
rc = blob_merge(&p, &m, &v, &r);
}
if( rc>=0 ){
if( !nochangeFlag ) blob_write_to_file(&r, zFullPath);
if( rc>0 ){
printf("***** %d merge conflicts in %s\n", rc, zName);
}
}else{
printf("***** Cannot merge binary file %s\n", zName);
}
free(zName);
|
| ︙ | ︙ | |||
320 321 322 323 324 325 326 |
** Clean up the mid and pid VFILE entries. Then commit the changes.
*/
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
if( !pickFlag ){
db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
}
undo_finish();
| | | 329 330 331 332 333 334 335 336 337 |
** Clean up the mid and pid VFILE entries. Then commit the changes.
*/
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
if( !pickFlag ){
db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
}
undo_finish();
db_end_transaction(nochangeFlag);
}
|