[PATCH 6 of 9 v2] bundlerepo: introduce method to discard file chunks and use it
Augie Fackler
raf at durin42.com
Fri Aug 5 13:23:44 EDT 2016
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1470416878 14400
# Fri Aug 05 13:07:58 2016 -0400
# Node ID 7e585d431acf066bf97ac7ccf8d16044206d5931
# Parent 8f8a9c204d704878faabbeca4c6c011ebc0a088e
bundlerepo: introduce method to discard file chunks and use it
This moves us to the modern iter() technique instead of the `while
True` pattern since it's easy. Factored out as a function because I'm
about to need this in a second place.
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -233,6 +233,10 @@ class bundlephasecache(phases.phasecache
self.invalidate()
self.dirty = True
+def _discarddeltachunks(bundle):
+ for chunk in iter(lambda: bundle.deltachunk(None), {}):
+ pass
+
class bundlerepository(localrepo.localrepository):
def __init__(self, ui, path, bundlename):
def _writetempbundle(read, suffix, header=''):
@@ -351,10 +355,7 @@ class bundlerepository(localrepo.localre
for chunkdata in iter(self.bundle.filelogheader, {}):
fname = chunkdata['filename']
self.bundlefilespos[fname] = self.bundle.tell()
- while True:
- c = self.bundle.deltachunk(None)
- if not c:
- break
+ _discarddeltachunks(self.bundle)
if f in self.bundlefilespos:
self.bundle.seek(self.bundlefilespos[f])
More information about the Mercurial-devel
mailing list