diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -442,6 +442,9 @@ class localrepository(object): 'aggressivemergedeltas', False) self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui) + chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan', -1) + if 0 <= chainspan: + self.svfs.options['maxdeltachainspan'] = chainspan for r in self.requirements: if r.startswith('exp-compression-'): diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -292,6 +292,7 @@ class revlog(object): self._nodecache = {nullid: nullrev} self._nodepos = None self._compengine = 'zlib' + self._maxdeltachainspan = -1 v = REVLOG_DEFAULT_VERSION opts = getattr(opener, 'options', None) @@ -313,6 +314,8 @@ class revlog(object): self._lazydeltabase = bool(opts.get('lazydeltabase', False)) if 'compengine' in opts: self._compengine = opts['compengine'] + if 'maxdeltachainspan' in opts: + self._maxdeltachainspan = opts['maxdeltachainspan'] if self._chunkcachesize <= 0: raise RevlogError(_('revlog chunk cache size %r is not greater ' @@ -1659,7 +1662,13 @@ class revlog(object): # - 'compresseddeltalen' is the sum of the total size of deltas we need # to apply -- bounding it limits the amount of CPU we consume. dist, l, data, base, chainbase, chainlen, compresseddeltalen = d - if (dist > textlen * 4 or l > textlen or + + defaultmax = textlen * 4 + maxdist = self._maxdeltachainspan + if not maxdist: + maxdist = dist # ensure the conditional pass + maxdist = max(maxdist, defaultmax) + if (dist > maxdist or l > textlen or compresseddeltalen > textlen * 2 or (self._maxchainlen and chainlen > self._maxchainlen)): return False diff --git a/tests/test-generaldelta.t b/tests/test-generaldelta.t --- a/tests/test-generaldelta.t +++ b/tests/test-generaldelta.t @@ -161,3 +161,191 @@ Test that strip bundle use bundle2 1c5d4dc9a8b8d6e1750966d343e94db665e7a1e9 draft $ cd .. + +test maxdeltachainspan + + $ hg init source-repo + $ cd source-repo + $ hg debugbuilddag --new-file '.+5:brancha$.+11:branchb$.+30:branchc