Mercurial > hg
changeset 51350:670e68729aa7
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.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 07 Jan 2024 03:13:36 +0100 |
parents | cc806f20d756 |
children | bbbfa00d1e67 |
files | mercurial/revlogutils/deltas.py tests/test-sparse-revlog.t |
diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlogutils/deltas.py Sun Jan 07 02:38:38 2024 +0100 +++ b/mercurial/revlogutils/deltas.py Sun Jan 07 03:13:36 2024 +0100 @@ -1067,7 +1067,7 @@ 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 @@ 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 @@ 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 @@ revinfo, candidaterev, target_rev=target_rev, + as_snapshot=search.current_stage == _STAGE_SNAPSHOT, ) if self._debug_search: delta_end = util.timer()
--- a/tests/test-sparse-revlog.t Sun Jan 07 02:38:38 2024 +0100 +++ b/tests/test-sparse-revlog.t Sun Jan 07 03:13:36 2024 +0100 @@ -279,7 +279,7 @@ 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