[PATCH 1 of 3] bundle2: Now that we have a seek implementation, use it

Eric Sumner ericsumner at fb.com
Thu Feb 5 19:10:29 UTC 2015


# HG changeset patch
# User Eric Sumner <ericsumner at fb.com>
# Date 1423162565 28800
#      Thu Feb 05 10:56:05 2015 -0800
# Node ID 8eeb3f4489fbe9c66d2ac0a8fd90abc973619bbc
# Parent  7f375d2de945e0e773541773db9c334f9e9f75c6
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.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -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):


More information about the Mercurial-devel mailing list