D7177: [PoC] allow providing explicit mapping for parents of merge commits
joerg.sonnenberger (Joerg Sonnenberger)
phabricator at mercurial-scm.org
Mon Oct 28 16:17:35 UTC 2019
joerg.sonnenberger created this revision.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Consider the following DAG:
C C'
| \ / |
|
A B D
with the goal of rebasing C to C' while switching the A parent to D.
This can happen when dealing with manual rebases of merges without
obsolescence markers.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D7177
AFFECTED FILES
hgext/rebase.py
CHANGE DETAILS
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -189,6 +189,13 @@
self.activebookmark = None
self.destmap = {}
self.skipped = set()
+ self.parentmap = {}
+ for pm in opts.get(b'parentmap', []):
+ if pm.count(':') != 1:
+ raise error.Abort(_(b"--parentmap takes a pair of revisions"
+ b"separated by colon"))
+ oldp, newp = pm.split(":")
+ self.parentmap[int(oldp)] = int(newp)
self.collapsef = opts.get(b'collapse', False)
self.collapsemsg = cmdutil.logmessage(ui, opts)
@@ -614,6 +621,7 @@
self.state,
self.skipped,
self.obsoletenotrebased,
+ self.parentmap,
)
if not self.inmemory and len(repo[None].parents()) == 2:
repo.ui.debug(b'resuming interrupted rebase\n')
@@ -870,6 +878,7 @@
_(b'read collapse commit message from file'),
_(b'FILE'),
),
+ (b'p', b'parentmap', [], _(b'map old parent to new parent'), _(b'REV:REV')),
(b'k', b'keep', False, _(b'keep original changesets')),
(b'', b'keepbranches', False, _(b'keep original branch names')),
(b'D', b'detach', False, _(b'(DEPRECATED)')),
@@ -1649,7 +1658,7 @@
yield nodemap[s]
-def defineparents(repo, rev, destmap, state, skipped, obsskipped):
+def defineparents(repo, rev, destmap, state, skipped, obsskipped, parentmap):
"""Return new parents and optionally a merge base for rev being rebased
The destination specified by "dest" cannot always be used directly because
@@ -1707,6 +1716,8 @@
np = dests[i]
elif p in state and state[p] > 0:
np = state[p]
+ elif p in parentmap:
+ np = parentmap[p]
# "bases" only record "special" merge bases that cannot be
# calculated from changelog DAG (i.e. isancestor(p, np) is False).
To: joerg.sonnenberger, martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list