diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -983,6 +983,9 @@ coreconfigitem('storage', 'revlog.optimi default=True, alias=[('format', 'aggressivemergedeltas')], ) +coreconfigitem('storage', 'revlog.reuse-external-delta', + default=True, +) coreconfigitem('storage', 'revlog.reuse-external-delta-parent', default=None, ) diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -1865,6 +1865,22 @@ category impact performance and reposito 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`` ---------- diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -752,10 +752,14 @@ def resolverevlogstorevfsoptions(ui, req 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') diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -410,7 +410,10 @@ class revlog(object): 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: diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py --- a/mercurial/revlogutils/deltas.py +++ b/mercurial/revlogutils/deltas.py @@ -916,7 +916,7 @@ class deltacomputer(object): 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) diff --git a/tests/test-sparse-revlog.t b/tests/test-sparse-revlog.t --- a/tests/test-sparse-revlog.t +++ b/tests/test-sparse-revlog.t @@ -40,7 +40,7 @@ repeatedly while some of it changes rare > 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