# HG changeset patch # User Pierre-Yves David # Date 2024-01-07 02:13:36 # Node ID 670e68729aa730d280626b61293e8cb0c68f3151 # Parent cc806f20d756f6ecc5f651cc20d3a54092a85e3a delta-find: stop using heuristic to determine if we are creating a snapshot This avoid assuming a changeset is a snapshot when it is actually something simpler. diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py --- a/mercurial/revlogutils/deltas.py +++ b/mercurial/revlogutils/deltas.py @@ -1067,7 +1067,7 @@ class _DeltaSearch(_BaseDeltaSearch): and good not in (self.p1, self.p2) and self.revlog.issnapshot(good) ): - self.current_stage = _STAGE_SNAPSHOT + assert self.current_stage == _STAGE_SNAPSHOT # refine snapshot down previous = None while previous != good: @@ -1336,7 +1336,9 @@ class deltacomputer: return delta - def _builddeltainfo(self, revinfo, base, target_rev=None): + def _builddeltainfo( + self, revinfo, base, target_rev=None, as_snapshot=False + ): # can we use the cached delta? revlog = self.revlog chainbase = revlog.chainbase(base) @@ -1354,7 +1356,8 @@ class deltacomputer: snapshotdepth = None if revlog.delta_config.sparse_revlog and deltabase == nullrev: snapshotdepth = 0 - elif revlog.delta_config.sparse_revlog and revlog.issnapshot(deltabase): + elif revlog.delta_config.sparse_revlog and as_snapshot: + assert revlog.issnapshot(deltabase) # A delta chain should always be one full snapshot, # zero or more semi-snapshots, and zero or more deltas p1, p2 = revlog.rev(revinfo.p1), revlog.rev(revinfo.p2) @@ -1679,6 +1682,7 @@ class deltacomputer: revinfo, candidaterev, target_rev=target_rev, + as_snapshot=search.current_stage == _STAGE_SNAPSHOT, ) if self._debug_search: delta_end = util.timer() 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 @@ -279,7 +279,7 @@ Test `debug-delta-find` DBG-DELTAS-SEARCH: uncompressed-delta-size=33050 DBG-DELTAS-SEARCH: delta-search-time=* (glob) DBG-DELTAS-SEARCH: DELTA: length=19179 (GOOD) - DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: delta-base=4930 is-cached=1 - search-rounds=1 try-count=1 - delta-type=snapshot snap-depth=4 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob) + DBG-DELTAS: FILELOG:SPARSE-REVLOG-TEST-FILE: rev=4971: delta-base=4930 is-cached=1 - search-rounds=1 try-count=1 - delta-type=delta snap-depth=-1 - p1-chain-length=15 p2-chain-length=-1 - duration=* (glob) $ hg debug-delta-find SPARSE-REVLOG-TEST-FILE 4971 --source p1 DBG-DELTAS-SEARCH: SEARCH rev=4971 DBG-DELTAS-SEARCH: ROUND #1 - 3 candidates - search-down