Fossil

Check-in [30050807]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the --cherrypick option to the "merge" command.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ssl
Files: files | file ages | folders
SHA1:3005080796a6d32f240e46926a0bbbfeb7641eea
User & Date: drh 2010-01-20 16:23:08
Context
2010-01-21
20:18
fix compile error check-in: 5fc80efd user: ron tags: ssl
2010-01-20
16:23
Add the --cherrypick option to the "merge" command. check-in: 30050807 user: drh tags: ssl
15:56
Pull in the latest fixes from the trunk. check-in: ac8902be user: drh tags: ssl
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/merge.c.

28
29
30
31
32
33
34
35
36
37
38



39
40
41
42
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
77
78

79
80
81
82
83
84
85
86
87
...
283
284
285
286
287
288
289

290

291
292
293
#include "merge.h"
#include <assert.h>


/*
** COMMAND: merge
**
** Usage: %fossil merge VERSION
**
** The argument is a version that should be merged into the current
** checkout. 



**
** Only file content is merged.  The result continues to use the
** file and directory names from the current check-out even if those
** names might have been changed in the branch being merged in.
*/
void merge_cmd(void){
  int vid;              /* Current version */
  int mid;              /* Version we are merging against */
  int pid;              /* The pivot version - most recent common ancestor */


  Stmt q;
  int detailFlag;

  detailFlag = find_option("detail",0,0)!=0;

  if( g.argc!=3 ){
    usage("VERSION");
  }
  db_must_be_within_tree();
  vid = db_lget_int("checkout", 0);
  if( vid==0 ){
    fossil_panic("nothing is checked out");
  }
  mid = name_to_rid(g.argv[2]);
  if( mid==0 ){
    fossil_panic("not a version: %s", g.argv[2]);
  }
  if( mid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", mid) ){
    fossil_panic("not a version: %s", g.argv[2]);
  }






  pivot_set_primary(mid);
  pivot_set_secondary(vid);
  db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0");
  while( db_step(&q)==SQLITE_ROW ){
    pivot_set_secondary(db_column_int(&q,0));
  }
  db_finalize(&q);
  pid = pivot_find();
  if( pid<=0 ){
    fossil_panic("cannot find a common ancestor between the current"
                 "checkout and %s", g.argv[2]);
  }

  if( pid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", pid) ){
    fossil_panic("not a version: record #%d", mid);
  }
  vfile_check_signature(vid, 1);
  db_begin_transaction();
  undo_begin();
  load_vfile_from_rid(mid);
  load_vfile_from_rid(pid);

................................................................................
  }
  db_finalize(&q);
  
  /*
  ** Clean up the mid and pid VFILE entries.  Then commit the changes.
  */
  db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);

  db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);

  undo_finish();
  db_end_transaction(0);
}







|


|
>
>
>









>
>

<


>






|



|


|

>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
>

|







 







>
|
>



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
295
296
297
298
299
300
301
302
303
304
305
306
307
#include "merge.h"
#include <assert.h>


/*
** COMMAND: merge
**
** Usage: %fossil merge [--cherrypick] VERSION
**
** The argument is a version that should be merged into the current
** checkout.  All changes from VERSION back to the nearest common
** ancestor are merged.  Except, if the --cherrypick option is used
** only the changes associated with the single check-in VERSION are
** merged.
**
** Only file content is merged.  The result continues to use the
** file and directory names from the current check-out even if those
** names might have been changed in the branch being merged in.
*/
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 */
  Stmt q;


  detailFlag = find_option("detail",0,0)!=0;
  pickFlag = find_option("cherrypick",0,0)!=0;
  if( g.argc!=3 ){
    usage("VERSION");
  }
  db_must_be_within_tree();
  vid = db_lget_int("checkout", 0);
  if( vid==0 ){
    fossil_fatal("nothing is checked out");
  }
  mid = name_to_rid(g.argv[2]);
  if( mid==0 ){
    fossil_fatal("not a version: %s", g.argv[2]);
  }
  if( mid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", mid) ){
    fossil_fatal("not a version: %s", g.argv[2]);
  }
  if( pickFlag ){
    pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
    if( pid<=0 ){
      fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
    }
  }else{
    pivot_set_primary(mid);
    pivot_set_secondary(vid);
    db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0");
    while( db_step(&q)==SQLITE_ROW ){
      pivot_set_secondary(db_column_int(&q,0));
    }
    db_finalize(&q);
    pid = pivot_find();
    if( pid<=0 ){
      fossil_fatal("cannot find a common ancestor between the current"
                   "checkout and %s", g.argv[2]);
    }
  }
  if( pid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", pid) ){
    fossil_fatal("not a version: record #%d", mid);
  }
  vfile_check_signature(vid, 1);
  db_begin_transaction();
  undo_begin();
  load_vfile_from_rid(mid);
  load_vfile_from_rid(pid);

................................................................................
  }
  db_finalize(&q);
  
  /*
  ** 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(0);
}