Submitter | Augie Fackler |
---|---|
Date | Aug. 5, 2016, 5:23 p.m. |
Message ID | <7e585d431acf066bf97a.1470417824@arthedain.pit.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/16125/ |
State | Superseded |
Headers | show |
Comments
On Fri, Aug 5, 2016 at 10:23 AM, Augie Fackler <raf@durin42.com> wrote: > # HG changeset patch > # User Augie Fackler <augie@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() I haven't tested it myself, but it looks like these three lines could also be extracted into a helper for the last patch in this series. Something like a findfilepositions() returning a dict. _discarddeltachunks() would then be called from a single place and can be inlined again. > - 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]) > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
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])