# HG changeset patch # User Boris Feld # Date 1536333452 14400 # Node ID 5b308a4e6d030104677fe08af4d0c4ae578a806b # Parent 2f9f7889549b78e5238ab9618cf229d16bedc456 snapshot: use None as a stop value when looking for a good delta Having clear stop value should help keep clear logic around the co-routine. The alternative of using a StopIteration exception give a messier result. This is one small step toward turning `_refinegroups` into a co-routine. diff -r 2f9f7889549b -r 5b308a4e6d03 mercurial/revlogutils/deltas.py --- a/mercurial/revlogutils/deltas.py Fri Sep 07 11:17:32 2018 -0400 +++ b/mercurial/revlogutils/deltas.py Fri Sep 07 11:17:32 2018 -0400 @@ -577,6 +577,7 @@ """ # should we try to build a delta? if not (len(revlog) and revlog._storedeltachains): + yield None return deltalength = revlog.length @@ -612,6 +613,7 @@ # impacting performances. Some bounding or slicing mecanism # would help to reduce this impact. yield tuple(group) + yield None def _findsnapshots(revlog, cache, start_rev): """find snapshot from start_rev to tip""" @@ -842,7 +844,8 @@ p1r, p2r = revlog.rev(p1), revlog.rev(p2) groups = _candidategroups(self.revlog, revinfo.textlen, p1r, p2r, cachedelta) - for candidaterevs in groups: + candidaterevs = next(groups) + while candidaterevs is not None: nominateddeltas = [] for candidaterev in candidaterevs: candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh) @@ -851,6 +854,7 @@ if nominateddeltas: deltainfo = min(nominateddeltas, key=lambda x: x.deltalen) break + candidaterevs = next(groups) if deltainfo is None: deltainfo = self._fullsnapshotinfo(fh, revinfo)