bundle2.unbundlepart: tell() implementation
authorEric Sumner <ericsumner@fb.com>
Wed, 14 Jan 2015 15:57:57 -0800
changeset 24036 c7601086338a
parent 24035 7eb26415bef6
child 24037 f0b498cfc5c8
bundle2.unbundlepart: tell() implementation Keep track of how many bytes we've returned from read(); fairly straightforward.
mercurial/bundle2.py
--- a/mercurial/bundle2.py	Wed Jan 14 14:46:23 2015 -0800
+++ b/mercurial/bundle2.py	Wed Jan 14 15:57:57 2015 -0800
@@ -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': (),