changeset 41824:688fc33e105d

storage: introduce a `revlog.reuse-external-delta` config This option goes a bit further and provides a way to get the same behavior as the `re-delta-all` optimisation from `hg debugupgraderepo`. The effect of the option is a bit hard to test as we do not have multiple diff algorithm at hand. However, we at least make sure the code path run.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 27 Feb 2019 12:40:18 +0100
parents f6eff9e4de80
children 9d38b4b52061
files mercurial/configitems.py mercurial/help/config.txt mercurial/localrepo.py mercurial/revlog.py mercurial/revlogutils/deltas.py tests/test-sparse-revlog.t
diffstat 6 files changed, 31 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Wed Feb 27 10:49:25 2019 +0100
+++ b/mercurial/configitems.py	Wed Feb 27 12:40:18 2019 +0100
@@ -983,6 +983,9 @@
     default=True,
     alias=[('format', 'aggressivemergedeltas')],
 )
+coreconfigitem('storage', 'revlog.reuse-external-delta',
+    default=True,
+)
 coreconfigitem('storage', 'revlog.reuse-external-delta-parent',
     default=None,
 )
--- a/mercurial/help/config.txt	Wed Feb 27 10:49:25 2019 +0100
+++ b/mercurial/help/config.txt	Wed Feb 27 12:40:18 2019 +0100
@@ -1865,6 +1865,22 @@
     considered.  Even when disabled, the existing delta from the source will be
     reused if the same delta parent is selected.
 
+``revlog.reuse-external-delta``
+    Control the reuse of delta from external source.
+    (typically: apply bundle from `hg pull` or `hg push`).
+
+    New revisions are usually provided as a delta against another revision. By
+    default, Mercurial will not recompute the same delta again, trusting
+    externally provided deltas. There have been rare cases of small adjustment
+    to the diffing algorithm in the past. So in some rare case, recomputing
+    delta provided by ancient clients can provides better results. Disabling
+    this option means going through a full delta recomputation for all incoming
+    revisions. It means a large increase in CPU usage and will slow operations
+    down.
+
+    This option is enabled by default. When disabled, it also disables the
+    related ``storage.revlog.reuse-external-delta-parent`` option.
+
 ``server``
 ----------
 
--- a/mercurial/localrepo.py	Wed Feb 27 10:49:25 2019 +0100
+++ b/mercurial/localrepo.py	Wed Feb 27 12:40:18 2019 +0100
@@ -752,10 +752,14 @@
                                      b'revlog.optimize-delta-parent-choice')
     options[b'deltabothparents'] = deltabothparents
 
-    lazydeltabase = ui.configbool(b'storage',
-                                  b'revlog.reuse-external-delta-parent')
+    lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
+    lazydeltabase = False
+    if lazydelta:
+        lazydeltabase = ui.configbool(b'storage',
+                                      b'revlog.reuse-external-delta-parent')
     if lazydeltabase is None:
         lazydeltabase = not scmutil.gddeltaconfig(ui)
+    options[b'lazydelta'] = lazydelta
     options[b'lazydeltabase'] = lazydeltabase
 
     chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
--- a/mercurial/revlog.py	Wed Feb 27 10:49:25 2019 +0100
+++ b/mercurial/revlog.py	Wed Feb 27 12:40:18 2019 +0100
@@ -410,7 +410,10 @@
             self._maxchainlen = opts['maxchainlen']
         if 'deltabothparents' in opts:
             self._deltabothparents = opts['deltabothparents']
-        self._lazydeltabase = bool(opts.get('lazydeltabase', False))
+        self._lazydelta = bool(opts.get('lazydelta', True))
+        self._lazydeltabase = False
+        if self._lazydelta:
+            self._lazydeltabase = bool(opts.get('lazydeltabase', False))
         if 'compengine' in opts:
             self._compengine = opts['compengine']
         if 'maxdeltachainspan' in opts:
--- a/mercurial/revlogutils/deltas.py	Wed Feb 27 10:49:25 2019 +0100
+++ b/mercurial/revlogutils/deltas.py	Wed Feb 27 12:40:18 2019 +0100
@@ -916,7 +916,7 @@
                     and currentbase != base
                     and self.revlog.length(currentbase) == 0):
                 currentbase = self.revlog.deltaparent(currentbase)
-            if currentbase == base:
+            if self.revlog._lazydelta and currentbase == base:
                 delta = revinfo.cachedelta[1]
         if delta is None:
             delta = self._builddeltadiff(base, revinfo, fh)
--- a/tests/test-sparse-revlog.t	Wed Feb 27 10:49:25 2019 +0100
+++ b/tests/test-sparse-revlog.t	Wed Feb 27 12:40:18 2019 +0100
@@ -40,7 +40,7 @@
   > maxchainlen = 15
   > [storage]
   > revlog.optimize-delta-parent-choice = yes
-  > revlog.reuse-external-delta-parent = no
+  > revlog.reuse-external-delta = no
   > EOF
   $ hg init sparse-repo
   $ cd sparse-repo