[PATCH 10 of 19] snapshot: use None as a stop value when looking for a good delta
Boris Feld
boris.feld at octobus.net
Sat Sep 8 06:57:04 EDT 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1536333452 14400
# Fri Sep 07 11:17:32 2018 -0400
# Node ID 256a998ee3bf645cc6eee3a144e6825d61406a7c
# Parent 9ea2ef9abc22291b021b80c8f88320026ae79618
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 256a998ee3bf
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 --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -577,6 +577,7 @@ def _candidategroups(revlog, textlen, p1
"""
# should we try to build a delta?
if not (len(revlog) and revlog._storedeltachains):
+ yield None
return
deltalength = revlog.length
@@ -612,6 +613,7 @@ def _candidategroups(revlog, textlen, p1
# 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 @@ class deltacomputer(object):
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 @@ class deltacomputer(object):
if nominateddeltas:
deltainfo = min(nominateddeltas, key=lambda x: x.deltalen)
break
+ candidaterevs = next(groups)
if deltainfo is None:
deltainfo = self._fullsnapshotinfo(fh, revinfo)
More information about the Mercurial-devel
mailing list