Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 22902:ce0592328d68
merge: add merge.graft helper
This will help unify all the open-coded graft/rebase operations.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 13 Oct 2014 17:12:12 -0500 |
parents | 18b3869179f9 |
children | 2793ecb1522d |
comparison
equal
deleted
inserted
replaced
22901:722117c8e023 | 22902:ce0592328d68 |
---|---|
1147 wlock.release() | 1147 wlock.release() |
1148 | 1148 |
1149 if not partial: | 1149 if not partial: |
1150 repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) | 1150 repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) |
1151 return stats | 1151 return stats |
1152 | |
1153 def graft(repo, ctx, pctx, labels): | |
1154 """Do a graft-like merge. | |
1155 | |
1156 This is a merge where the merge ancestor is chosen such that one | |
1157 or more changesets are grafted onto the current changeset. In | |
1158 addition to the merge, this fixes up the dirstate to include only | |
1159 a single parent and tries to duplicate any renames/copies | |
1160 appropriately. | |
1161 | |
1162 ctx - changeset to rebase | |
1163 pctx - merge base, usually ctx.p1() | |
1164 labels - merge labels eg ['local', 'graft'] | |
1165 | |
1166 """ | |
1167 | |
1168 stats = update(repo, ctx.node(), True, True, False, pctx.node(), | |
1169 labels=labels) | |
1170 # drop the second merge parent | |
1171 repo.dirstate.beginparentchange() | |
1172 repo.setparents(repo['.'].node(), nullid) | |
1173 repo.dirstate.write() | |
1174 # fix up dirstate for copies and renames | |
1175 copies.duplicatecopies(repo, ctx.rev(), pctx.rev()) | |
1176 repo.dirstate.endparentchange() | |
1177 return stats |