Patchwork [09,of,11,V2] revlogdeltas: pass revision number to _candidatesgroups

login
register
mail settings
Submitter Boris Feld
Date Aug. 27, 2018, 10:06 a.m.
Message ID <9368d13b35f9d40ce74e.1535364396@FB-lair>
Download mbox | patch
Permalink /patch/34073/
State Accepted
Headers show

Comments

Boris Feld - Aug. 27, 2018, 10:06 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1534570325 -7200
#      Sat Aug 18 07:32:05 2018 +0200
# Node ID 9368d13b35f9d40ce74ec4f242ff13eef895d2a4
# Parent  9bf51f196a9fc3a08a567957d4253198035939e5
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9368d13b35f9
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.

Patch

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -576,7 +576,6 @@  def _candidategroups(revlog, p1, p2, cac
     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 @@  def _candidategroups(revlog, p1, p2, cac
 
         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:
@@ -735,7 +734,8 @@  class deltacomputer(object):
 
         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