Mercurial > hg-stable
changeset 51359:cc806f20d756
delta-find: explicitly track stage of the search
Being more explicit about what we are doing is going to be useful. We actually
start making use of it in later changesets.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 07 Jan 2024 02:38:38 +0100 |
parents | d58e14262587 |
children | 670e68729aa7 |
files | mercurial/revlogutils/deltas.py |
diffstat | 1 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlogutils/deltas.py Thu Nov 23 20:09:34 2023 +0100 +++ b/mercurial/revlogutils/deltas.py Sun Jan 07 02:38:38 2024 +0100 @@ -590,6 +590,20 @@ # consider these candidates. LIMIT_BASE2TEXT = 500 +### stage of the search, used for debug and to select and to adjust some logic. +# initial stage, next step is unknown +_STAGE_UNSPECIFIED = "unspecified" +# trying the cached delta +_STAGE_CACHED = "cached" +# trying delta based on parents +_STAGE_PARENTS = "parents" +# trying to build a valid snapshot of any level +_STAGE_SNAPSHOT = "snapshot" +# trying to build a delta based of the previous revision +_STAGE_PREV = "prev" +# trying to build a full snapshot +_STAGE_FULL = "full" + class _BaseDeltaSearch(abc.ABC): """perform the search of a good delta for a single revlog revision @@ -634,6 +648,7 @@ self.tested = {nullrev} + self.current_stage = _STAGE_UNSPECIFIED self.current_group = None self._init_group() @@ -790,7 +805,7 @@ """ def _init_group(self): - pass + self.current_stage = _STAGE_FULL def next_group(self, good_delta=None): pass @@ -804,9 +819,11 @@ """ def _init_group(self): + self.current_stage = _STAGE_PREV self.current_group = [self.target_rev - 1] def next_group(self, good_delta=None): + self.current_stage = _STAGE_FULL self.current_group = None @@ -1026,6 +1043,7 @@ ): # Assume what we received from the server is a good choice # build delta will reuse the cache + self.current_stage = _STAGE_CACHED good = yield (self.cachedelta[0],) if good is not None: yield None @@ -1039,6 +1057,7 @@ # If sparse revlog is enabled, we can try to refine the available # deltas if not self.revlog.delta_config.sparse_revlog: + self.current_stage = _STAGE_FULL yield None return @@ -1048,6 +1067,7 @@ and good not in (self.p1, self.p2) and self.revlog.issnapshot(good) ): + self.current_stage = _STAGE_SNAPSHOT # refine snapshot down previous = None while previous != good: @@ -1067,6 +1087,7 @@ ) good = yield children + self.current_stage = _STAGE_FULL yield None def _raw_groups(self): @@ -1084,6 +1105,7 @@ # exclude already lazy tested base if any parents = [p for p in (self.p1, self.p2) if p != nullrev] + self.current_stage = _STAGE_PARENTS if ( not self.revlog.delta_config.delta_both_parents and len(parents) == 2 @@ -1099,6 +1121,7 @@ yield parents if sparse and parents: + self.current_stage = _STAGE_SNAPSHOT # See if we can use an existing snapshot in the parent chains to # use as a base for a new intermediate-snapshot # @@ -1188,6 +1211,7 @@ if not sparse: # other approach failed try against prev to hopefully save us a # fulltext. + self.current_stage = _STAGE_PREV yield (prev,)