Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 51043: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 | e2941c398f10 |
children | 59c6f99723b1 |
comparison
equal
deleted
inserted
replaced
51042:127656e0b97b | 51043:f636103c4d67 |
---|---|
871 | 871 |
872 self.nodeconstants = sha1nodeconstants | 872 self.nodeconstants = sha1nodeconstants |
873 self.nullid = self.nodeconstants.nullid | 873 self.nullid = self.nodeconstants.nullid |
874 | 874 |
875 # sparse-revlog can't be on without general-delta (issue6056) | 875 # sparse-revlog can't be on without general-delta (issue6056) |
876 if not self._generaldelta: | 876 if not self.delta_config.general_delta: |
877 self.delta_config.sparse_revlog = False | 877 self.delta_config.sparse_revlog = False |
878 | 878 |
879 self._storedeltachains = True | 879 self._storedeltachains = True |
880 | 880 |
881 devel_nodemap = ( | 881 devel_nodemap = ( |
1251 def _chaininfo(self, rev): | 1251 def _chaininfo(self, rev): |
1252 chaininfocache = self._chaininfocache | 1252 chaininfocache = self._chaininfocache |
1253 if rev in chaininfocache: | 1253 if rev in chaininfocache: |
1254 return chaininfocache[rev] | 1254 return chaininfocache[rev] |
1255 index = self.index | 1255 index = self.index |
1256 generaldelta = self._generaldelta | 1256 generaldelta = self.delta_config.general_delta |
1257 iterrev = rev | 1257 iterrev = rev |
1258 e = index[iterrev] | 1258 e = index[iterrev] |
1259 clen = 0 | 1259 clen = 0 |
1260 compresseddeltalen = 0 | 1260 compresseddeltalen = 0 |
1261 while iterrev != e[3]: | 1261 while iterrev != e[3]: |
1287 | 1287 |
1288 Returns a 2-tuple of (chain, stopped) where ``chain`` is a list of | 1288 Returns a 2-tuple of (chain, stopped) where ``chain`` is a list of |
1289 revs in ascending order and ``stopped`` is a bool indicating whether | 1289 revs in ascending order and ``stopped`` is a bool indicating whether |
1290 ``stoprev`` was hit. | 1290 ``stoprev`` was hit. |
1291 """ | 1291 """ |
1292 generaldelta = self.delta_config.general_delta | |
1292 # Try C implementation. | 1293 # Try C implementation. |
1293 try: | 1294 try: |
1294 return self.index.deltachain(rev, stoprev, self._generaldelta) | 1295 return self.index.deltachain(rev, stoprev, generaldelta) |
1295 except AttributeError: | 1296 except AttributeError: |
1296 pass | 1297 pass |
1297 | 1298 |
1298 chain = [] | 1299 chain = [] |
1299 | 1300 |
1300 # Alias to prevent attribute lookup in tight loop. | 1301 # Alias to prevent attribute lookup in tight loop. |
1301 index = self.index | 1302 index = self.index |
1302 generaldelta = self._generaldelta | |
1303 | 1303 |
1304 iterrev = rev | 1304 iterrev = rev |
1305 e = index[iterrev] | 1305 e = index[iterrev] |
1306 while iterrev != e[3] and iterrev != stoprev: | 1306 while iterrev != e[3] and iterrev != stoprev: |
1307 chain.append(iterrev) | 1307 chain.append(iterrev) |
2060 def deltaparent(self, rev): | 2060 def deltaparent(self, rev): |
2061 """return deltaparent of the given revision""" | 2061 """return deltaparent of the given revision""" |
2062 base = self.index[rev][3] | 2062 base = self.index[rev][3] |
2063 if base == rev: | 2063 if base == rev: |
2064 return nullrev | 2064 return nullrev |
2065 elif self._generaldelta: | 2065 elif self.delta_config.general_delta: |
2066 return base | 2066 return base |
2067 else: | 2067 else: |
2068 return rev - 1 | 2068 return rev - 1 |
2069 | 2069 |
2070 def issnapshot(self, rev): | 2070 def issnapshot(self, rev): |
2784 | 2784 |
2785 if cachedelta is not None and len(cachedelta) == 2: | 2785 if cachedelta is not None and len(cachedelta) == 2: |
2786 # If the cached delta has no information about how it should be | 2786 # If the cached delta has no information about how it should be |
2787 # reused, add the default reuse instruction according to the | 2787 # reused, add the default reuse instruction according to the |
2788 # revlog's configuration. | 2788 # revlog's configuration. |
2789 if self._generaldelta and self._lazydeltabase: | 2789 if ( |
2790 self.delta_config.general_delta | |
2791 and self.delta_config.lazy_delta_base | |
2792 ): | |
2790 delta_base_reuse = DELTA_BASE_REUSE_TRY | 2793 delta_base_reuse = DELTA_BASE_REUSE_TRY |
2791 else: | 2794 else: |
2792 delta_base_reuse = DELTA_BASE_REUSE_NO | 2795 delta_base_reuse = DELTA_BASE_REUSE_NO |
2793 cachedelta = (cachedelta[0], cachedelta[1], delta_base_reuse) | 2796 cachedelta = (cachedelta[0], cachedelta[1], delta_base_reuse) |
2794 | 2797 |
3002 raise error.ProgrammingError(b'cannot nest addgroup() calls') | 3005 raise error.ProgrammingError(b'cannot nest addgroup() calls') |
3003 | 3006 |
3004 # read the default delta-base reuse policy from revlog config if the | 3007 # read the default delta-base reuse policy from revlog config if the |
3005 # group did not specify one. | 3008 # group did not specify one. |
3006 if delta_base_reuse_policy is None: | 3009 if delta_base_reuse_policy is None: |
3007 if self._generaldelta and self._lazydeltabase: | 3010 if ( |
3011 self.delta_config.general_delta | |
3012 and self.delta_config.lazy_delta_base | |
3013 ): | |
3008 delta_base_reuse_policy = DELTA_BASE_REUSE_TRY | 3014 delta_base_reuse_policy = DELTA_BASE_REUSE_TRY |
3009 else: | 3015 else: |
3010 delta_base_reuse_policy = DELTA_BASE_REUSE_NO | 3016 delta_base_reuse_policy = DELTA_BASE_REUSE_NO |
3011 | 3017 |
3012 self._adding_group = True | 3018 self._adding_group = True |
3249 if nodesorder not in (b'nodes', b'storage', b'linear', None): | 3255 if nodesorder not in (b'nodes', b'storage', b'linear', None): |
3250 raise error.ProgrammingError( | 3256 raise error.ProgrammingError( |
3251 b'unhandled value for nodesorder: %s' % nodesorder | 3257 b'unhandled value for nodesorder: %s' % nodesorder |
3252 ) | 3258 ) |
3253 | 3259 |
3254 if nodesorder is None and not self._generaldelta: | 3260 if nodesorder is None and not self.delta_config.general_delta: |
3255 nodesorder = b'storage' | 3261 nodesorder = b'storage' |
3256 | 3262 |
3257 if ( | 3263 if ( |
3258 not self._storedeltachains | 3264 not self._storedeltachains |
3259 and deltamode != repository.CG_DELTAMODE_PREV | 3265 and deltamode != repository.CG_DELTAMODE_PREV |