Fossil SCM
Add the --baseline option to the "merge" command to facilitate merging of subsections of a branch.
Commit
f7b4517ca7f51d0e4a3369381d57c4b89916da59
Parent
a2a5e2948b18cb7…
1 file changed
+22
-10
+22
-10
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -40,10 +40,15 @@ | ||
| 40 | 40 | ** file and directory names from the current checkout even if those |
| 41 | 41 | ** names might have been changed in the branch being merged in. |
| 42 | 42 | ** |
| 43 | 43 | ** Other options: |
| 44 | 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 | +** | |
| 45 | 50 | ** --detail Show additional details of the merge |
| 46 | 51 | ** |
| 47 | 52 | ** --binary GLOBPATTERN Treat files that match GLOBPATTERN as binary |
| 48 | 53 | ** and do not try to merge parallel changes. This |
| 49 | 54 | ** option overrides the "binary-glob" setting. |
| @@ -58,10 +63,11 @@ | ||
| 58 | 63 | int detailFlag; /* True if the --detail option is present */ |
| 59 | 64 | int pickFlag; /* True if the --cherrypick option is present */ |
| 60 | 65 | int backoutFlag; /* True if the --backout option is present */ |
| 61 | 66 | int nochangeFlag; /* True if the --nochange or -n option is present */ |
| 62 | 67 | const char *zBinGlob; /* The value of --binary */ |
| 68 | + const char *zPivot; /* The value of --baseline */ | |
| 63 | 69 | int debugFlag; /* True if --debug is present */ |
| 64 | 70 | int nChng; /* Number of file name changes */ |
| 65 | 71 | int *aChng; /* An array of file name changes */ |
| 66 | 72 | int i; /* Loop counter */ |
| 67 | 73 | int nConflict = 0; /* Number of conflicts seen */ |
| @@ -80,10 +86,11 @@ | ||
| 80 | 86 | pickFlag = find_option("cherrypick",0,0)!=0; |
| 81 | 87 | backoutFlag = find_option("backout",0,0)!=0; |
| 82 | 88 | debugFlag = find_option("debug",0,0)!=0; |
| 83 | 89 | zBinGlob = find_option("binary",0,1); |
| 84 | 90 | nochangeFlag = find_option("nochange","n",0)!=0; |
| 91 | + zPivot = find_option("baseline",0,1); | |
| 85 | 92 | if( g.argc!=3 ){ |
| 86 | 93 | usage("VERSION"); |
| 87 | 94 | } |
| 88 | 95 | db_must_be_within_tree(); |
| 89 | 96 | if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0); |
| @@ -90,26 +97,26 @@ | ||
| 90 | 97 | vid = db_lget_int("checkout", 0); |
| 91 | 98 | if( vid==0 ){ |
| 92 | 99 | fossil_fatal("nothing is checked out"); |
| 93 | 100 | } |
| 94 | 101 | mid = name_to_rid(g.argv[2]); |
| 95 | - if( mid==0 ){ | |
| 102 | + if( mid==0 || !is_a_version(mid) ){ | |
| 96 | 103 | fossil_fatal("not a version: %s", g.argv[2]); |
| 97 | 104 | } |
| 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 ){ | |
| 102 | 114 | pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid); |
| 103 | 115 | if( pid<=0 ){ |
| 104 | 116 | fossil_fatal("cannot find an ancestor for %s", g.argv[2]); |
| 105 | 117 | } |
| 106 | - if( backoutFlag ){ | |
| 107 | - int t = pid; | |
| 108 | - pid = mid; | |
| 109 | - mid = t; | |
| 110 | - } | |
| 111 | 118 | }else{ |
| 112 | 119 | pivot_set_primary(mid); |
| 113 | 120 | pivot_set_secondary(vid); |
| 114 | 121 | db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0"); |
| 115 | 122 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -119,10 +126,15 @@ | ||
| 119 | 126 | pid = pivot_find(); |
| 120 | 127 | if( pid<=0 ){ |
| 121 | 128 | fossil_fatal("cannot find a common ancestor between the current " |
| 122 | 129 | "checkout and %s", g.argv[2]); |
| 123 | 130 | } |
| 131 | + } | |
| 132 | + if( backoutFlag ){ | |
| 133 | + int t = pid; | |
| 134 | + pid = mid; | |
| 135 | + mid = t; | |
| 124 | 136 | } |
| 125 | 137 | if( !is_a_version(pid) ){ |
| 126 | 138 | fossil_fatal("not a version: record #%d", pid); |
| 127 | 139 | } |
| 128 | 140 | vfile_check_signature(vid, 1, 0); |
| 129 | 141 |
| --- 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 |