Mercurial > hg
changeset 51046:f636103c4d67
revlog: remove legacy usage of `_generaldelta`
All core code is now getting the setting from the DeltaConfig object.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 10 Oct 2023 10:56:42 +0200 |
parents | 127656e0b97b |
children | 861fe9273d57 |
files | mercurial/debugcommands.py mercurial/revlog.py mercurial/revlogutils/deltas.py mercurial/revlogutils/rewrite.py tests/bundles/test-revlog-diff-relative-to-nullrev.sh |
diffstat | 5 files changed, 23 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Tue Oct 10 18:02:20 2023 +0200 +++ b/mercurial/debugcommands.py Tue Oct 10 10:56:42 2023 +0200 @@ -805,7 +805,7 @@ index = r.index start = r.start length = r.length - generaldelta = r._generaldelta + generaldelta = r.delta_config.general_delta withsparseread = getattr(r, '_withsparseread', False) # security to avoid crash on corrupted revlogs
--- a/mercurial/revlog.py Tue Oct 10 18:02:20 2023 +0200 +++ b/mercurial/revlog.py Tue Oct 10 10:56:42 2023 +0200 @@ -873,7 +873,7 @@ self.nullid = self.nodeconstants.nullid # sparse-revlog can't be on without general-delta (issue6056) - if not self._generaldelta: + if not self.delta_config.general_delta: self.delta_config.sparse_revlog = False self._storedeltachains = True @@ -1253,7 +1253,7 @@ if rev in chaininfocache: return chaininfocache[rev] index = self.index - generaldelta = self._generaldelta + generaldelta = self.delta_config.general_delta iterrev = rev e = index[iterrev] clen = 0 @@ -1289,9 +1289,10 @@ revs in ascending order and ``stopped`` is a bool indicating whether ``stoprev`` was hit. """ + generaldelta = self.delta_config.general_delta # Try C implementation. try: - return self.index.deltachain(rev, stoprev, self._generaldelta) + return self.index.deltachain(rev, stoprev, generaldelta) except AttributeError: pass @@ -1299,7 +1300,6 @@ # Alias to prevent attribute lookup in tight loop. index = self.index - generaldelta = self._generaldelta iterrev = rev e = index[iterrev] @@ -2062,7 +2062,7 @@ base = self.index[rev][3] if base == rev: return nullrev - elif self._generaldelta: + elif self.delta_config.general_delta: return base else: return rev - 1 @@ -2786,7 +2786,10 @@ # If the cached delta has no information about how it should be # reused, add the default reuse instruction according to the # revlog's configuration. - if self._generaldelta and self._lazydeltabase: + if ( + self.delta_config.general_delta + and self.delta_config.lazy_delta_base + ): delta_base_reuse = DELTA_BASE_REUSE_TRY else: delta_base_reuse = DELTA_BASE_REUSE_NO @@ -3004,7 +3007,10 @@ # read the default delta-base reuse policy from revlog config if the # group did not specify one. if delta_base_reuse_policy is None: - if self._generaldelta and self._lazydeltabase: + if ( + self.delta_config.general_delta + and self.delta_config.lazy_delta_base + ): delta_base_reuse_policy = DELTA_BASE_REUSE_TRY else: delta_base_reuse_policy = DELTA_BASE_REUSE_NO @@ -3251,7 +3257,7 @@ b'unhandled value for nodesorder: %s' % nodesorder ) - if nodesorder is None and not self._generaldelta: + if nodesorder is None and not self.delta_config.general_delta: nodesorder = b'storage' if (
--- a/mercurial/revlogutils/deltas.py Tue Oct 10 18:02:20 2023 +0200 +++ b/mercurial/revlogutils/deltas.py Tue Oct 10 10:56:42 2023 +0200 @@ -597,7 +597,7 @@ assert ( revinfo.cachedelta is None or revinfo.cachedelta[2] != DELTA_BASE_REUSE_FORCE - or not revlog._generaldelta + or not revlog.delta_config.general_delta ) # - 'deltainfo.distance' is the distance from the base revision -- @@ -695,7 +695,7 @@ if target_rev is None: target_rev = len(revlog) - if not revlog._generaldelta: + if not revlog.delta_config.general_delta: # before general delta, there is only one possible delta base yield (target_rev - 1,) yield None @@ -707,7 +707,7 @@ assert ( cachedelta is None or cachedelta[2] != DELTA_BASE_REUSE_FORCE - or not revlog._generaldelta + or not revlog.delta_config.general_delta ) deltalength = revlog.length @@ -908,7 +908,7 @@ The group order aims at providing fast or small candidates first. """ # Why search for delta base if we cannot use a delta base ? - assert revlog._generaldelta + assert revlog.delta_config.general_delta # also see issue6056 sparse = revlog._sparserevlog curr = len(revlog) @@ -1140,7 +1140,7 @@ # can we use the cached delta? revlog = self.revlog chainbase = revlog.chainbase(base) - if revlog._generaldelta: + if revlog.delta_config.general_delta: deltabase = base else: if target_rev is not None and base != target_rev - 1: @@ -1317,7 +1317,7 @@ # If this source delta are to be forcibly reuse, let us comply early. if ( - revlog._generaldelta + revlog.delta_config.general_delta and revinfo.cachedelta is not None and revinfo.cachedelta[2] == DELTA_BASE_REUSE_FORCE ):
--- a/mercurial/revlogutils/rewrite.py Tue Oct 10 18:02:20 2023 +0200 +++ b/mercurial/revlogutils/rewrite.py Tue Oct 10 10:56:42 2023 +0200 @@ -75,7 +75,7 @@ ) newrl._format_version = rl._format_version newrl._format_flags = rl._format_flags - newrl.delta_config.general_delta = rl._generaldelta + newrl.delta_config.general_delta = rl.delta_config.general_delta newrl._parse_index = rl._parse_index for rev in rl.revs():
--- a/tests/bundles/test-revlog-diff-relative-to-nullrev.sh Tue Oct 10 18:02:20 2023 +0200 +++ b/tests/bundles/test-revlog-diff-relative-to-nullrev.sh Tue Oct 10 10:56:42 2023 +0200 @@ -12,7 +12,7 @@ # # if deltainfo is None: # - deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev) -# + if revlog._generaldelta: +# + if revlog.delta_config.general_delta: # + deltainfo = self._builddeltainfo(revinfo, nullrev, fh) # + else: # + deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev)