Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 24643:a8e6897dffbe
graft: allow creating sibling grafts
Previously it was impossible to graft a commit onto it's own parent (i.e. create
a copy of the commit). This is useful when wanting to create a backup of the
commit before continuing to amend it. This patch enables that behavior.
The change to the histedit test is because histedit uses graft to apply commits.
The test in question moves a commit backwards onto an ancestor. Since the graft
logic now more explicitly supports this, it knows to simply accept the incoming
changes (since they are more recent), instead of prompting.
author | Durham Goode <durham@fb.com> |
---|---|
date | Sun, 05 Apr 2015 11:55:38 -0700 |
parents | 1ff35d76421c |
children | 51844b8b5017 |
comparison
equal
deleted
inserted
replaced
24642:54e5c239c2d9 | 24643:a8e6897dffbe |
---|---|
1182 ctx - changeset to rebase | 1182 ctx - changeset to rebase |
1183 pctx - merge base, usually ctx.p1() | 1183 pctx - merge base, usually ctx.p1() |
1184 labels - merge labels eg ['local', 'graft'] | 1184 labels - merge labels eg ['local', 'graft'] |
1185 | 1185 |
1186 """ | 1186 """ |
1187 # If we're grafting a descendant onto an ancestor, be sure to pass | |
1188 # mergeancestor=True to update. This does two things: 1) allows the merge if | |
1189 # the destination is the same as the parent of the ctx (so we can use graft | |
1190 # to copy commits), and 2) informs update that the incoming changes are | |
1191 # newer than the destination so it doesn't prompt about "remote changed foo | |
1192 # which local deleted". | |
1193 mergeancestor = repo.changelog.isancestor(repo['.'].node(), ctx.node()) | |
1187 | 1194 |
1188 stats = update(repo, ctx.node(), True, True, False, pctx.node(), | 1195 stats = update(repo, ctx.node(), True, True, False, pctx.node(), |
1189 labels=labels) | 1196 mergeancestor=mergeancestor, labels=labels) |
1197 | |
1190 # drop the second merge parent | 1198 # drop the second merge parent |
1191 repo.dirstate.beginparentchange() | 1199 repo.dirstate.beginparentchange() |
1192 repo.setparents(repo['.'].node(), nullid) | 1200 repo.setparents(repo['.'].node(), nullid) |
1193 repo.dirstate.write() | 1201 repo.dirstate.write() |
1194 # fix up dirstate for copies and renames | 1202 # fix up dirstate for copies and renames |