changeset 854:86b826399dfd

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 03 Mar 2014 22:46:46 -0800
parents b82b49189328
children b6337585ae25
files hgext/evolve.py
diffstat 1 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -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))