# HG changeset patch # User Pierre-Yves David # Date 1393915606 28800 # Node ID 86b826399dfdceb3126a929a4ca38670c4006eca # Parent b82b491893285d069f3305bcfe984d10a3ba8b97 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. diff -r b82b49189328 -r 86b826399dfd 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))