# HG changeset patch # User Pierre-Yves David # Date 1700772703 -3600 # Node ID 5cc04a6da19d0f4e730f894906cb26c4cadd9a26 # Parent 7083b33a26992ed3ef14472924c06a92663eb3fe delta-find: move the emotion of parents in a dedicated method After splitting the filtering, and with the `_candidate_groups` layer removed, we can start splitting the group generation too. This helps to organize this code and make it easier to modifying the future. diff -r 7083b33a2699 -r 5cc04a6da19d mercurial/revlogutils/deltas.py --- a/mercurial/revlogutils/deltas.py Sun Jan 07 03:08:46 2024 +0100 +++ b/mercurial/revlogutils/deltas.py Thu Nov 23 21:51:43 2023 +0100 @@ -1055,6 +1055,25 @@ return True + def _iter_parents(self): + # 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 + ): + parents.sort() + # To minimize the chance of having to build a fulltext, + # pick first whichever parent is closest to us (max rev) + yield (parents[1],) + # then the other one (min rev) if the first did not fit + yield (parents[0],) + elif len(parents) > 0: + # Test all parents (1 or 2), and keep the best candidate + yield parents + def _refined_groups(self): good = None groups = self._raw_groups() @@ -1107,28 +1126,12 @@ The group order aims at providing fast or small candidates first. """ + yield from self._iter_parents() sparse = self.revlog.delta_config.sparse_revlog prev = self.target_rev - 1 deltachain = lambda rev: self.revlog._deltachain(rev)[0] - # 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 - ): - parents.sort() - # To minimize the chance of having to build a fulltext, - # pick first whichever parent is closest to us (max rev) - yield (parents[1],) - # then the other one (min rev) if the first did not fit - yield (parents[0],) - elif len(parents) > 0: - # Test all parents (1 or 2), and keep the best candidate - yield parents - if sparse and parents: self.current_stage = _STAGE_SNAPSHOT # See if we can use an existing snapshot in the parent chains to