Patchwork [12,of,19] snapshot: also use None as a stop value for `_refinegroup`

login
register
mail settings
Submitter Boris Feld
Date Sept. 8, 2018, 10:57 a.m.
Message ID <f79dc24022976ab6ba0a.1536404226@localhost.localdomain>
Download mbox | patch
Permalink /patch/34435/
State Accepted
Headers show

Comments

Boris Feld - Sept. 8, 2018, 10:57 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1536333453 14400
#      Fri Sep 07 11:17:33 2018 -0400
# Node ID f79dc24022976ab6ba0a8f7183651e0e4d9877d5
# Parent  db3775d10e1167be3487eed8b915ca2bf8c4bccb
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f79dc2402297
snapshot: also use None as a stop value for `_refinegroup`

This is yet another small step toward turning `_refinegroups` into a co-routine.

Patch

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -587,7 +587,11 @@  def _candidategroups(revlog, textlen, p1
     deltas_limit = textlen * LIMIT_DELTA2TEXT
 
     tested = set([nullrev])
-    for temptative in _refinedgroups(revlog, p1, p2, cachedelta):
+    candidates = _refinedgroups(revlog, p1, p2, cachedelta)
+    while True:
+        temptative = next(candidates)
+        if temptative is None:
+            break
         group = []
         for rev in temptative:
             # skip over empty delta (no need to include them in a chain)
@@ -632,6 +636,8 @@  def _refinedgroups(revlog, p1, p2, cache
         good = yield candidates
         if good is not None:
             break
+    # we have found nothing
+    yield None
 
 def _rawgroups(revlog, p1, p2, cachedelta):
     """Provides group of revision to be tested as delta base