[PATCH 3 of 3 V3] rebase: add revs variant of revlog.findmissing and use it to compute detach set

Siddharth Agarwal sid0 at fb.com
Mon Nov 26 14:00:34 CST 2012


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1353955704 28800
# Node ID 233770157e86466c7885c3529f71d4ac663e2533
# Parent  f43c3f9f8f8608fbe1c7a36d9ea43764e2f46e21
rebase: add revs variant of revlog.findmissing and use it to compute detach set

diff -r f43c3f9f8f86 -r 233770157e86 hgext/rebase.py
--- a/hgext/rebase.py	Mon Nov 26 11:02:48 2012 -0800
+++ b/hgext/rebase.py	Mon Nov 26 10:48:24 2012 -0800
@@ -656,9 +656,12 @@
     #
     # The actual abort is handled by `defineparents`
     if len(root.parents()) <= 1:
-        # (strict) ancestors of <root> not ancestors of <dest>
-        detachset = repo.revs('::%d - ::%d - %d', root, commonbase, root)
+        # ancestors of <root> not ancestors of <dest>
+        detachset = repo.changelog.findmissingrevs([commonbase.rev()],
+            [root.rev()])
         state.update(dict.fromkeys(detachset, nullmerge))
+        # detachset can have root, and we definitely want to rebase that
+        state[root.rev()] = nullrev
     return repo['.'].rev(), dest.rev(), state
 
 def clearrebased(ui, repo, state, collapsedas=None):
diff -r f43c3f9f8f86 -r 233770157e86 mercurial/revlog.py
--- a/mercurial/revlog.py	Mon Nov 26 11:02:48 2012 -0800
+++ b/mercurial/revlog.py	Mon Nov 26 10:48:24 2012 -0800
@@ -430,6 +430,29 @@
         missing.sort()
         return has, [self.node(r) for r in missing]
 
+    def findmissingrevs(self, common=None, heads=None):
+        """Return the revision numbers of the ancestors of heads that
+        are not ancestors of common.
+
+        More specifically, return a list of revision numbers corresponding to
+        nodes N such that every N satisfies the following constraints:
+
+          1. N is an ancestor of some node in 'heads'
+          2. N is not an ancestor of any node in 'common'
+
+        The list is sorted by revision number, meaning it is
+        topologically sorted.
+
+        'heads' and 'common' are both lists of revision numbers.  If heads is
+        not supplied, uses all of the revlog's heads.  If common is not
+        supplied, uses nullid."""
+        if common is None:
+            common = [nullrev]
+        if heads is None:
+            heads = self.headrevs()
+
+        return ancestor.missingancestors(heads, common, self.parentrevs)
+
     def findmissing(self, common=None, heads=None):
         """Return the ancestors of heads that are not ancestors of common.
 


More information about the Mercurial-devel mailing list