emitrevision: add a small closure to check if a base is usable stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 28 Nov 2022 15:48:51 +0100
branchstable
changeset 49785 fa955e3f6aee
parent 49784 e45590649888
child 49786 0bda07f34c01
emitrevision: add a small closure to check if a base is usable We will make more use of this and make it more complex too.
mercurial/utils/storageutil.py
--- a/mercurial/utils/storageutil.py	Thu Dec 08 15:13:17 2022 +0100
+++ b/mercurial/utils/storageutil.py	Mon Nov 28 15:48:51 2022 +0100
@@ -391,6 +391,9 @@
     # Set of revs available to delta against.
     available = set()
 
+    def is_usable_base(rev):
+        return rev != nullrev and rev in available
+
     for rev in revs:
         if rev == nullrev:
             continue
@@ -420,7 +423,7 @@
         elif deltaparentrev != nullrev:
             # Base revision was already emitted in this group. We can
             # always safely use the delta.
-            if deltaparentrev in available:
+            if is_usable_base(deltaparentrev):
                 baserev = deltaparentrev
 
             # Base revision is a parent that hasn't been emitted already.