| 1 |
.TH HG GRAFT "" "" "" |
| 2 |
.SH NAME |
| 3 |
hg graft \- copy changes from other branches onto the current branch |
| 4 |
.\" Man page generated from reStructuredText. |
| 5 |
. |
| 6 |
.SH SYNOPSIS |
| 7 |
.sp |
| 8 |
.nf |
| 9 |
.ft C |
| 10 |
hg graft [OPTION]... [\-r REV]... REV... |
| 11 |
.ft P |
| 12 |
.fi |
| 13 |
.SH DESCRIPTION |
| 14 |
.sp |
| 15 |
This command uses Mercurial\(aqs merge logic to copy individual |
| 16 |
changes from other branches without merging branches in the |
| 17 |
history graph. This is sometimes known as \(aqbackporting\(aq or |
| 18 |
\(aqcherry\-picking\(aq. By default, graft will copy user, date, and |
| 19 |
description from the source changesets. |
| 20 |
.sp |
| 21 |
Changesets that are ancestors of the current revision, that have |
| 22 |
already been grafted, or that are merges will be skipped. |
| 23 |
.sp |
| 24 |
If \-\-log is specified, log messages will have a comment appended |
| 25 |
of the form: |
| 26 |
.sp |
| 27 |
.nf |
| 28 |
.ft C |
| 29 |
(grafted from CHANGESETHASH) |
| 30 |
.ft P |
| 31 |
.fi |
| 32 |
.sp |
| 33 |
If \-\-force is specified, revisions will be grafted even if they |
| 34 |
are already ancestors of, or have been grafted to, the destination. |
| 35 |
This is useful when the revisions have since been backed out. |
| 36 |
.sp |
| 37 |
If a graft merge results in conflicts, the graft process is |
| 38 |
interrupted so that the current merge can be manually resolved. |
| 39 |
Once all conflicts are addressed, the graft process can be |
| 40 |
continued with the \-c/\-\-continue option. |
| 41 |
.sp |
| 42 |
The \-c/\-\-continue option reapplies all the earlier options. |
| 43 |
.sp |
| 44 |
The \-\-base option exposes more of how graft internally uses merge with a |
| 45 |
custom base revision. \-\-base can be used to specify another ancestor than |
| 46 |
the first and only parent. |
| 47 |
.sp |
| 48 |
The command: |
| 49 |
.sp |
| 50 |
.nf |
| 51 |
.ft C |
| 52 |
hg graft \-r 345 \-\-base 234 |
| 53 |
.ft P |
| 54 |
.fi |
| 55 |
.sp |
| 56 |
is thus pretty much the same as: |
| 57 |
.sp |
| 58 |
.nf |
| 59 |
.ft C |
| 60 |
hg diff \-\-from 234 \-\-to 345 | hg import |
| 61 |
.ft P |
| 62 |
.fi |
| 63 |
.sp |
| 64 |
but using merge to resolve conflicts and track moved files. |
| 65 |
.sp |
| 66 |
The result of a merge can thus be backported as a single commit by |
| 67 |
specifying one of the merge parents as base, and thus effectively |
| 68 |
grafting the changes from the other side. |
| 69 |
.sp |
| 70 |
It is also possible to collapse multiple changesets and clean up history |
| 71 |
by specifying another ancestor as base, much like rebase \-\-collapse |
| 72 |
\-\-keep. |
| 73 |
.sp |
| 74 |
The commit message can be tweaked after the fact using commit \-\-amend . |
| 75 |
.sp |
| 76 |
For using non\-ancestors as the base to backout changes, see the backout |
| 77 |
command and the hidden \-\-parent option. |
| 78 |
.sp |
| 79 |
The experimental \-\-to option allows grafting a revision in\-memory, |
| 80 |
independent of the working copy. Merge conflicts are not currently |
| 81 |
supported, and the operation will be aborted if the configured tool |
| 82 |
cannot handle the conflicts that might be encountered. |
| 83 |
.sp |
| 84 |
As the operation is performed in\-memory, the on\-disk files will not be |
| 85 |
modified, and some hooks might not be run. |
| 86 |
.sp |
| 87 |
Examples: |
| 88 |
.INDENT 0.0 |
| 89 |
.IP \(bu 2 |
| 90 |
. |
| 91 |
copy a single change to the stable branch and edit its description: |
| 92 |
.sp |
| 93 |
.nf |
| 94 |
.ft C |
| 95 |
hg update stable |
| 96 |
hg graft \-\-edit 9393 |
| 97 |
.ft P |
| 98 |
.fi |
| 99 |
.IP \(bu 2 |
| 100 |
. |
| 101 |
graft a range of changesets with one exception, updating dates: |
| 102 |
.sp |
| 103 |
.nf |
| 104 |
.ft C |
| 105 |
hg graft \-D "2085::2093 and not 2091" |
| 106 |
.ft P |
| 107 |
.fi |
| 108 |
.IP \(bu 2 |
| 109 |
. |
| 110 |
continue a graft after resolving conflicts: |
| 111 |
.sp |
| 112 |
.nf |
| 113 |
.ft C |
| 114 |
hg graft \-c |
| 115 |
.ft P |
| 116 |
.fi |
| 117 |
.IP \(bu 2 |
| 118 |
. |
| 119 |
show the source of a grafted changeset: |
| 120 |
.sp |
| 121 |
.nf |
| 122 |
.ft C |
| 123 |
hg log \-\-debug \-r . |
| 124 |
.ft P |
| 125 |
.fi |
| 126 |
.IP \(bu 2 |
| 127 |
. |
| 128 |
show revisions sorted by date: |
| 129 |
.sp |
| 130 |
.nf |
| 131 |
.ft C |
| 132 |
hg log \-r "sort(all(), date)" |
| 133 |
.ft P |
| 134 |
.fi |
| 135 |
.IP \(bu 2 |
| 136 |
. |
| 137 |
backport the result of a merge as a single commit: |
| 138 |
.sp |
| 139 |
.nf |
| 140 |
.ft C |
| 141 |
hg graft \-r 123 \-\-base 123^ |
| 142 |
.ft P |
| 143 |
.fi |
| 144 |
.IP \(bu 2 |
| 145 |
. |
| 146 |
land a feature branch as one changeset: |
| 147 |
.sp |
| 148 |
.nf |
| 149 |
.ft C |
| 150 |
hg up \-cr default |
| 151 |
hg graft \-r featureX \-\-base "ancestor(\(aqfeatureX\(aq, \(aqdefault\(aq)" |
| 152 |
.ft P |
| 153 |
.fi |
| 154 |
.UNINDENT |
| 155 |
.sp |
| 156 |
See \%\fBhg help revisions\fP\: for more about specifying revisions. |
| 157 |
.sp |
| 158 |
Returns 0 on successful completion, 1 if there are unresolved files. |
| 159 |
.SH OPTIONS |
| 160 |
.INDENT 0.0 |
| 161 |
.TP |
| 162 |
.BI \-r, \-\-rev \ <REV[+]> |
| 163 |
. |
| 164 |
revisions to graft |
| 165 |
.TP |
| 166 |
.BI \-\-base \ <REV> |
| 167 |
. |
| 168 |
base revision when doing the graft merge (ADVANCED) |
| 169 |
.TP |
| 170 |
.BI \-\-to \ <VALUE> |
| 171 |
. |
| 172 |
graft to this destination, in\-memory (EXPERIMENTAL) |
| 173 |
.TP |
| 174 |
.B \-c, \-\-continue |
| 175 |
. |
| 176 |
resume interrupted graft |
| 177 |
.TP |
| 178 |
.B \-\-stop |
| 179 |
. |
| 180 |
stop interrupted graft |
| 181 |
.TP |
| 182 |
.B \-\-abort |
| 183 |
. |
| 184 |
abort interrupted graft |
| 185 |
.TP |
| 186 |
.B \-e, \-\-edit |
| 187 |
. |
| 188 |
invoke editor on commit messages |
| 189 |
.TP |
| 190 |
.B \-\-log |
| 191 |
. |
| 192 |
append graft info to log message |
| 193 |
.TP |
| 194 |
.B \-\-no\-commit |
| 195 |
. |
| 196 |
don\(aqt commit, just apply the changes in working directory |
| 197 |
.TP |
| 198 |
.B \-f, \-\-force |
| 199 |
. |
| 200 |
force graft |
| 201 |
.TP |
| 202 |
.B \-D, \-\-currentdate |
| 203 |
. |
| 204 |
record the current date as commit date |
| 205 |
.TP |
| 206 |
.B \-U, \-\-currentuser |
| 207 |
. |
| 208 |
record the current user as committer |
| 209 |
.TP |
| 210 |
.BI \-d, \-\-date \ <DATE> |
| 211 |
. |
| 212 |
record the specified date as commit date |
| 213 |
.TP |
| 214 |
.BI \-u, \-\-user \ <USER> |
| 215 |
. |
| 216 |
record the specified user as committer |
| 217 |
.TP |
| 218 |
.BI \-t, \-\-tool \ <TOOL> |
| 219 |
. |
| 220 |
specify merge tool |
| 221 |
.TP |
| 222 |
.B \-n, \-\-dry\-run |
| 223 |
. |
| 224 |
do not perform actions, just print output |
| 225 |
.UNINDENT |
| 226 |
.sp |
| 227 |
[+] marked option can be specified multiple times |
| 228 |
.\" Generated by docutils manpage writer. |
| 229 |
.\" |
| 230 |
. |