Mercurial > hg
changeset 39498:04b75f3a3f2a
snapshot: add refining logic at the findeltainfo level
Once we found a delta, we want to have the candidates logic challenge it,
searching for a better candidate.
The logic at the lower level is still missing. We'll introduce it later.
Adding small changes in individual commits make it simpler to explain the code
change.
This is another small step toward turning `_refinegroups` into a co-routine.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 07 Sep 2018 11:17:33 -0400 |
parents | 5b308a4e6d03 |
children | 51cec7fb672e |
files | mercurial/revlogutils/deltas.py |
diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlogutils/deltas.py Fri Sep 07 11:17:32 2018 -0400 +++ b/mercurial/revlogutils/deltas.py Fri Sep 07 11:17:33 2018 -0400 @@ -582,6 +582,7 @@ deltalength = revlog.length deltaparent = revlog.deltaparent + good = None deltas_limit = textlen * LIMIT_DELTA2TEXT @@ -612,7 +613,9 @@ # XXX: in the sparse revlog case, group can become large, # impacting performances. Some bounding or slicing mecanism # would help to reduce this impact. - yield tuple(group) + good = yield tuple(group) + if good is not None: + break yield None def _findsnapshots(revlog, cache, start_rev): @@ -847,14 +850,20 @@ candidaterevs = next(groups) while candidaterevs is not None: nominateddeltas = [] + if deltainfo is not None: + # if we already found a good delta, + # challenge it against refined candidates + nominateddeltas.append(deltainfo) for candidaterev in candidaterevs: candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh) if isgooddeltainfo(self.revlog, candidatedelta, revinfo): nominateddeltas.append(candidatedelta) if nominateddeltas: deltainfo = min(nominateddeltas, key=lambda x: x.deltalen) - break - candidaterevs = next(groups) + if deltainfo is not None: + candidaterevs = groups.send(deltainfo.base) + else: + candidaterevs = next(groups) if deltainfo is None: deltainfo = self._fullsnapshotinfo(fh, revinfo)