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

login
register
mail settings
Submitter Eric Sumner
Date Feb. 4, 2015, 7:29 p.m.
Message ID <34be4c79b05ea59a75e2.1423078177@waste.org>
Download mbox | patch
Permalink /patch/7670/
State Accepted
Commit c7601086338a12fd915d544d1af3e75750576d2e
Headers show

Comments

Eric Sumner - Feb. 4, 2015, 7:29 p.m.
# HG changeset patch
# User Eric Sumner <ericsumner@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.

Patch

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': (),