changeset 49386:1e12ea7d8435 stable

git: copy findmissingrevs() from revlog.py to gitlog.py (issue6472)
author Anton Shestakov <av6@dwimlabs.net>
date Wed, 06 Jul 2022 11:52:26 +0400
parents 3c4d36a96a3e
children be3828081624
files hgext/git/gitlog.py tests/test-git-interop.t
diffstat 2 files changed, 29 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/git/gitlog.py	Mon Jul 04 17:16:13 2022 +0400
+++ b/hgext/git/gitlog.py	Wed Jul 06 11:52:26 2022 +0400
@@ -282,6 +282,30 @@
 
         return ancestor.incrementalmissingancestors(self.parentrevs, common)
 
+    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()
+
+        inc = self.incrementalmissingrevs(common=common)
+        return inc.missingancestors(heads)
+
     def findmissing(self, common=None, heads=None):
         """Return the ancestors of heads that are not ancestors of common.
 
--- a/tests/test-git-interop.t	Mon Jul 04 17:16:13 2022 +0400
+++ b/tests/test-git-interop.t	Wed Jul 06 11:52:26 2022 +0400
@@ -425,5 +425,8 @@
   7[tip][master]   1a0fee76bfc4   1970-01-01 00:00 +0000   test
     remove beta
   
-
-
+This covers revlog.findmissingrevs() (issue6472)
+  $ hg log -r 'last(only(master))' -Tcompact
+  7[tip][master]   1a0fee76bfc4   1970-01-01 00:00 +0000   test
+    remove beta
+