[PATCH "V2] revlog: preserve `_lazydelta` attribute in `revlog.clone`

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Mar 5 09:37:59 EST 2019


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1551710814 -3600
#      Mon Mar 04 15:46:54 2019 +0100
# Node ID 951a1d74f8ea4576169d1437f1c0bcc82e3da586
# Parent  82d9728ace9535057d77df6c920385861ec00072
# EXP-Topic lazydelta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 951a1d74f8ea
revlog: preserve `_lazydelta` attribute in `revlog.clone`

The attribute was introduce in 688fc33e105d, Yuya Nishihara pointed out that
this preservation was missing. This changeset fixes the preservation and make
sure we set the attribute according the modes.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2396,21 +2396,25 @@ class revlog(object):
         if getattr(destrevlog, 'filteredrevs', None):
             raise ValueError(_('destination revlog has filtered revisions'))
 
-        # lazydeltabase controls whether to reuse a cached delta, if possible.
+        # lazydelta and lazydeltabase controls whether to reuse a cached delta,
+        # if possible.
+        oldlazydelta = destrevlog._lazydelta
         oldlazydeltabase = destrevlog._lazydeltabase
         oldamd = destrevlog._deltabothparents
 
         try:
             if deltareuse == self.DELTAREUSEALWAYS:
                 destrevlog._lazydeltabase = True
+                destrevlog._lazydelta = True
             elif deltareuse == self.DELTAREUSESAMEREVS:
                 destrevlog._lazydeltabase = False
+                destrevlog._lazydelta = True
+            elif deltareuse == self.DELTAREUSENEVER:
+                destrevlog._lazydeltabase = False
+                destrevlog._lazydelta = False
 
             destrevlog._deltabothparents = forcedeltabothparents or oldamd
 
-            populatecachedelta = deltareuse in (self.DELTAREUSEALWAYS,
-                                                self.DELTAREUSESAMEREVS)
-
             deltacomputer = deltautil.deltacomputer(destrevlog)
             index = self.index
             for rev in self:
@@ -2428,7 +2432,7 @@ class revlog(object):
                 # the revlog chunk is a delta.
                 cachedelta = None
                 rawtext = None
-                if populatecachedelta:
+                if destrevlog._lazydelta:
                     dp = self.deltaparent(rev)
                     if dp != nullrev:
                         cachedelta = (dp, bytes(self._chunk(rev)))
@@ -2460,6 +2464,7 @@ class revlog(object):
                 if addrevisioncb:
                     addrevisioncb(self, rev, node)
         finally:
+            destrevlog._lazydelta = oldlazydelta
             destrevlog._lazydeltabase = oldlazydeltabase
             destrevlog._deltabothparents = oldamd
 


More information about the Mercurial-devel mailing list