[PATCH 3 of 4] bundle2.unbundlepart: tell() implementation

Eric Sumner ericsumner at fb.com
Wed Feb 4 13:29:37 CST 2015


# HG changeset patch
# User Eric Sumner <ericsumner at fb.com>
# Date 1421279877 28800
#      Wed Jan 14 15:57:57 2015 -0800
# Node ID 34be4c79b05ea59a75e2e60f25839971c120126f
# Parent  5c1c0b2b4aa5b0bbab1310a01ead10b7f69f8dcd
bundle2.unbundlepart: tell() implementation

Keep track of how many bytes we've returned from read(); fairly straightforward.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -828,6 +828,7 @@
         self._readheader()
         self._mandatory = None
         self._chunkindex = [] #(payload, file) position tuples for chunk starts
+        self._pos = 0
 
     def _fromheader(self, size):
         """return the next <size> byte from the header"""
@@ -930,8 +931,12 @@
             data = self._payloadstream.read(size)
         if size is None or len(data) < size:
             self.consumed = True
+        self._pos += len(data)
         return data
 
+    def tell(self):
+        return self._pos
+
 capabilities = {'HG2Y': (),
                 'b2x:listkeys': (),
                 'b2x:pushkey': (),


More information about the Mercurial-devel mailing list