# HG changeset patch # User Pierre-Yves David # Date 1397688108 14400 # Node ID 07bcbf326c8d0bae27e75faaa62cacafebfae5f2 # Parent f4014f646f715d99c6c4885a3769da6b5100a316 bundle2: use an official iterparts method to unbundle parts Explicit is better than implicit. diff -r f4014f646f71 -r 07bcbf326c8d mercurial/bundle2.py --- a/mercurial/bundle2.py Fri Feb 28 02:52:32 2014 +0100 +++ b/mercurial/bundle2.py Wed Apr 16 18:41:48 2014 -0400 @@ -286,7 +286,7 @@ # - replace this is a init function soon. # - exception catching unbundler.params - iterparts = iter(unbundler) + iterparts = unbundler.iterparts() part = None try: for part in iterparts: @@ -397,7 +397,8 @@ class unbundle20(unpackermixin): """interpret a bundle2 stream - (this will eventually yield parts)""" + This class is fed with a binary stream and yields parts through its + `iterparts` methods.""" def __init__(self, ui, fp, header=None): """If header is specified, we do not read it out of the stream.""" @@ -450,7 +451,7 @@ raise KeyError(name) - def __iter__(self): + def iterparts(self): """yield all parts contained in the stream""" # make sure param have been loaded self.params diff -r f4014f646f71 -r 07bcbf326c8d tests/test-bundle2.t --- a/tests/test-bundle2.t Fri Feb 28 02:52:32 2014 +0100 +++ b/tests/test-bundle2.t Wed Apr 16 18:41:48 2014 -0400 @@ -143,7 +143,7 @@ > if value is not None: > ui.write(' %s\n' % value) > count = 0 - > for p in unbundler: + > for p in unbundler.iterparts(): > count += 1 > ui.write(' :%s:\n' % p.type) > ui.write(' mandatory: %i\n' % len(p.mandatoryparams))