revlogdeltas: pass revision number to _candidatesgroups
authorBoris Feld <boris.feld@octobus.net>
Sat, 18 Aug 2018 07:32:05 +0200
changeset 39335 1441eb38849f
parent 39334 507f5b1dd7c8
child 39336 1c6ff52fe9cf
revlogdeltas: pass revision number to _candidatesgroups The `_candidates_groups` logic works on revisions, so the nodes are currently just converted to revs at the top of the function. It seems cleaner to instead pass revision numbers to the function. Having this conversion out of the way will help for further cleanups.
mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py	Sat Aug 18 07:27:34 2018 +0200
+++ b/mercurial/revlogutils/deltas.py	Sat Aug 18 07:32:05 2018 +0200
@@ -576,7 +576,6 @@
     gdelta = revlog._generaldelta
     curr = len(revlog)
     prev = curr - 1
-    p1r, p2r = revlog.rev(p1), revlog.rev(p2)
 
     # should we try to build a delta?
     if prev != nullrev and revlog._storedeltachains:
@@ -593,7 +592,7 @@
 
         if gdelta:
             # exclude already lazy tested base if any
-            parents = [p for p in (p1r, p2r)
+            parents = [p for p in (p1, p2)
                        if p != nullrev and p not in tested]
 
             if not revlog._deltabothparents and len(parents) == 2:
@@ -734,7 +733,8 @@
 
         deltainfo = None
         deltas_limit = revinfo.textlen * LIMIT_DELTA2TEXT
-        groups = _candidategroups(self.revlog, p1, p2, cachedelta)
+        p1r, p2r = revlog.rev(p1), revlog.rev(p2)
+        groups = _candidategroups(self.revlog, p1r, p2r, cachedelta)
         for candidaterevs in groups:
             # filter out delta base that will never produce good delta
             candidaterevs = [r for r in candidaterevs