exchange: add progress bar when pushing using wire protocol command
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 03 Mar 2014 22:46:46 -0800
changeset 854 86b826399dfd
parent 853 b82b49189328
child 861 b6337585ae25
exchange: add progress bar when pushing using wire protocol command Progress bar on pull was only available for pushkey based push before this changeset. This implementation is very hacky but we are still at a proof of concept stage for those new exchange method.
hgext/evolve.py
--- a/hgext/evolve.py	Mon Mar 03 22:18:05 2014 -0800
+++ b/hgext/evolve.py	Mon Mar 03 22:46:46 2014 -0800
@@ -24,7 +24,7 @@
 
 import sys
 import random
-from cStringIO import StringIO
+from StringIO import StringIO
 import struct
 
 import mercurial
@@ -2110,6 +2110,20 @@
     for mark in markers:
         fp.write(obsolete._encodeonemarker(mark))
 
+class pushobsmarkerStringIO(StringIO):
+    """hacky string io for progress"""
+
+    @util.propertycache
+    def _length(self):
+        return len(self.getvalue())
+
+    def read(self, size):
+        self.ui.progress('OBSEXC', self.tell(), unit="bytes",
+                         total=self._length)
+        return StringIO.read(self, size)
+
+
+
 @eh.wrapfunction(exchange, '_pushobsolete')
 def _pushobsolete(orig, pushop):
     """utility function to push obsolete markers to a remote"""
@@ -2126,12 +2140,14 @@
         markers = repo.obsstore.relevantmarkers(nodes)
         if remote.capable('_evoext_pushobsmarkers_0'):
             repo.ui.status("OBSEXC: writing %i markers\n" % len(markers))
-            obsdata = StringIO()
+            obsdata = pushobsmarkerStringIO()
             _encodemarkersstream(obsdata, markers)
             obsdata.seek(0)
+            obsdata.ui = repo.ui
             repo.ui.status("OBSEXC: pushing %i bytes\n"
                            % len(obsdata.getvalue()))
             remote.evoext_pushobsmarkers_0(obsdata)
+            repo.ui.progress('OBSEXC', None)
         else:
             rslts = []
             repo.ui.status("OBSEXC: encoding %i markers\n" % len(markers))