changeset 39497:5b308a4e6d03

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.
author Boris Feld <boris.feld@octobus.net>
date Fri, 07 Sep 2018 11:17:32 -0400
parents 2f9f7889549b
children 04b75f3a3f2a
files mercurial/revlogutils/deltas.py
diffstat 1 files changed, 5 insertions(+), 1 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: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)