exchange: add progress bar when pulling using wire protocol command
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 03 Mar 2014 22:18:05 -0800
changeset 853 b82b49189328
parent 852 aa722de36179
child 854 86b826399dfd
exchange: add progress bar when pulling using wire protocol command progress bar on pull was only available for pushkey based pull before this changeset.
hgext/evolve.py
--- a/hgext/evolve.py	Mon Mar 03 21:37:18 2014 -0800
+++ b/hgext/evolve.py	Mon Mar 03 22:18:05 2014 -0800
@@ -2249,7 +2249,18 @@
     f = self._callstream("evoext_pullobsmarkers_0", **opts)
     f = self._decompress(f)
     length= int(f.read(20))
-    return StringIO(f.read(length))
+    chunk = 4096
+    current = 0
+    data = StringIO()
+    ui = self.ui
+    ui.progress('OBSEXC', current, unit="bytes", total=length)
+    while current < length:
+        readsize = min(length-current, chunk)
+        data.write(f.read(readsize))
+        current += readsize
+        ui.progress('OBSEXC', current, unit="bytes", total=length)
+    ui.progress('OBSEXC', None)
+    return data
 
 @eh.addattr(localrepo.localpeer, 'evoext_pullobsmarkers_0')
 def local_pullobsmarkers(self, heads=None, common=None):