changeset 21129:07bcbf326c8d

bundle2: use an official iterparts method to unbundle parts Explicit is better than implicit.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 16 Apr 2014 18:41:48 -0400
parents f4014f646f71
children 1ff06386217f
files mercurial/bundle2.py tests/test-bundle2.t
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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))