changeset 24047:731fa8e3e580

bundle2: now that we have a seek implementation, use it Replace bare part.read() calls with part.seek(0, 2) since the return value is being ignored. As this doesn't necessarily require building a string that contains the rest of the part, the potential exists to reduce the memory footprint of these operations.
author Eric Sumner <ericsumner@fb.com>
date Thu, 05 Feb 2015 10:56:05 -0800
parents 6e1d9f9932a9
children 13d88b7eb3a0
files mercurial/bundle2.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed Feb 04 22:25:35 2015 -0800
+++ b/mercurial/bundle2.py	Thu Feb 05 10:56:05 2015 -0800
@@ -313,7 +313,7 @@
     except Exception, exc:
         for part in iterparts:
             # consume the bundle content
-            part.read()
+            part.seek(0, 2)
         # Small hack to let caller code distinguish exceptions from bundle2
         # processing from processing the old format. This is mostly
         # needed to handle different return codes to unbundle according to the
@@ -365,7 +365,7 @@
             outpart.addparam('in-reply-to', str(part.id), mandatory=False)
     finally:
         # consume the part content to not corrupt the stream.
-        part.read()
+        part.seek(0, 2)
 
 
 def decodecaps(blob):