[PATCH 2 of 5 v3] rebase: return merge parents from defineparents which becomes computerebase

Mads Kiilerich mads at kiilerich.com
Wed Dec 3 21:12:46 CST 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1417052361 -3600
#      Thu Nov 27 02:39:21 2014 +0100
# Node ID 5a39fd5c40c861a0da05cbbc2f80fbedcda19835
# Parent  a20a470ffce95d5266b8e332c0e01c72604fc528
rebase: return merge parents from defineparents which becomes computerebase

So far the merge parents are trivial. Soon, we want to compute it more
carefully and correctly.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -370,8 +370,8 @@ def rebase(ui, repo, **opts):
             if state[rev] == -1:
                 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, repo[rev])),
                             _('changesets'), total)
-                p1, p2, base = defineparents(repo, rev, target, state,
-                                             targetancestors)
+                m1, m2, anc, p1, p2 = computerebase(repo, rev, target, state,
+                                                    targetancestors)
                 storestatus(repo, originalwd, target, state, collapsef, keepf,
                             keepbranchesf, external, activebookmark)
                 if len(repo.parents()) == 2:
@@ -380,7 +380,7 @@ def rebase(ui, repo, **opts):
                     try:
                         ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
                                      'rebase')
-                        stats = rebasenode(repo, rev, p1, base, state, collapsef,
+                        stats = rebasenode(repo, m2, m1, anc, state, collapsef,
                                            target)
                         if stats and stats[3] > 0:
                             raise error.InterventionRequired(
@@ -414,8 +414,8 @@ def rebase(ui, repo, **opts):
         ui.note(_('rebase merging completed\n'))
 
         if collapsef and not keepopen:
-            p1, p2, _base = defineparents(repo, min(state), target,
-                                          state, targetancestors)
+            _m1, _m2, _anc, p1, _p2 = computerebase(repo, min(state), target,
+                                                    state, targetancestors)
             editopt = opts.get('edit')
             editform = 'rebase.collapse'
             if collapsemsg:
@@ -578,8 +578,11 @@ def nearestrebased(repo, rev, state):
     else:
         return None
 
-def defineparents(repo, rev, target, state, targetancestors):
-    'Return the new parent relationship of the revision that will be rebased'
+def computerebase(repo, rev, target, state, targetancestors):
+    '''Return the merge revisions and new parent relationship of rev rebased
+    to target:
+        merge parent 1, merge parent 2, ancestor, new parent 1, new parent 2
+    '''
     parents = repo[rev].parents()
     p1 = p2 = nullrev
 
@@ -661,8 +664,8 @@ def defineparents(repo, rev, target, sta
 
             # Raise because this function is called wrong (see issue 4106)
             raise AssertionError('no base found to rebase on '
-                                 '(defineparents called wrong)')
-    return p1, p2, base
+                                 '(computerebase called wrong)')
+    return p1, rev, base, p1, p2
 
 def isagitpatch(repo, patchname):
     'Return true if the given patch is in git format'
@@ -919,7 +922,7 @@ def buildstate(repo, dest, rebaseset, co
         # | unrelated source | new parent is <dest> | ambiguous, abort        |
         # +------------------+----------------------+-------------------------+
         #
-        # The actual abort is handled by `defineparents`
+        # The actual abort is handled by `computerebase`
         if len(root.parents()) <= 1:
             # ancestors of <root> not ancestors of <dest>
             detachset.update(repo.changelog.findmissingrevs([commonbase.rev()],
@@ -931,7 +934,7 @@ def buildstate(repo, dest, rebaseset, co
         # If we have multiple roots, we may have "hole" in the rebase set.
         # Rebase roots that descend from those "hole" should not be detached as
         # other root are. We use the special `revignored` to inform rebase that
-        # the revision should be ignored but that `defineparents` should search
+        # the revision should be ignored but that `computerebase` should search
         # a rebase destination that make sense regarding rebased topology.
         rebasedomain = set(repo.revs('%ld::%ld', rebaseset, rebaseset))
         for ignored in set(rebasedomain) - set(rebaseset):


More information about the Mercurial-devel mailing list