comparison hgext/evolve.py @ 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
comparison
equal deleted inserted replaced
853:b82b49189328 854:86b826399dfd
22 testedwith = '2.7 2.7.1 2.7.2 2.8 2.8.1' 22 testedwith = '2.7 2.7.1 2.7.2 2.8 2.8.1'
23 buglink = 'https://bitbucket.org/marmoute/mutable-history/issues' 23 buglink = 'https://bitbucket.org/marmoute/mutable-history/issues'
24 24
25 import sys 25 import sys
26 import random 26 import random
27 from cStringIO import StringIO 27 from StringIO import StringIO
28 import struct 28 import struct
29 29
30 import mercurial 30 import mercurial
31 from mercurial import util 31 from mercurial import util
32 32
2108 def _encodemarkersstream(fp, markers): 2108 def _encodemarkersstream(fp, markers):
2109 fp.write(_pack('>B', 0)) 2109 fp.write(_pack('>B', 0))
2110 for mark in markers: 2110 for mark in markers:
2111 fp.write(obsolete._encodeonemarker(mark)) 2111 fp.write(obsolete._encodeonemarker(mark))
2112 2112
2113 class pushobsmarkerStringIO(StringIO):
2114 """hacky string io for progress"""
2115
2116 @util.propertycache
2117 def _length(self):
2118 return len(self.getvalue())
2119
2120 def read(self, size):
2121 self.ui.progress('OBSEXC', self.tell(), unit="bytes",
2122 total=self._length)
2123 return StringIO.read(self, size)
2124
2125
2126
2113 @eh.wrapfunction(exchange, '_pushobsolete') 2127 @eh.wrapfunction(exchange, '_pushobsolete')
2114 def _pushobsolete(orig, pushop): 2128 def _pushobsolete(orig, pushop):
2115 """utility function to push obsolete markers to a remote""" 2129 """utility function to push obsolete markers to a remote"""
2116 pushop.ui.debug('try to push obsolete markers to remote\n') 2130 pushop.ui.debug('try to push obsolete markers to remote\n')
2117 repo = pushop.repo 2131 repo = pushop.repo
2124 repo.ui.status("OBSEXC: computing markers relevant to %i nodes\n" 2138 repo.ui.status("OBSEXC: computing markers relevant to %i nodes\n"
2125 % len(nodes)) 2139 % len(nodes))
2126 markers = repo.obsstore.relevantmarkers(nodes) 2140 markers = repo.obsstore.relevantmarkers(nodes)
2127 if remote.capable('_evoext_pushobsmarkers_0'): 2141 if remote.capable('_evoext_pushobsmarkers_0'):
2128 repo.ui.status("OBSEXC: writing %i markers\n" % len(markers)) 2142 repo.ui.status("OBSEXC: writing %i markers\n" % len(markers))
2129 obsdata = StringIO() 2143 obsdata = pushobsmarkerStringIO()
2130 _encodemarkersstream(obsdata, markers) 2144 _encodemarkersstream(obsdata, markers)
2131 obsdata.seek(0) 2145 obsdata.seek(0)
2146 obsdata.ui = repo.ui
2132 repo.ui.status("OBSEXC: pushing %i bytes\n" 2147 repo.ui.status("OBSEXC: pushing %i bytes\n"
2133 % len(obsdata.getvalue())) 2148 % len(obsdata.getvalue()))
2134 remote.evoext_pushobsmarkers_0(obsdata) 2149 remote.evoext_pushobsmarkers_0(obsdata)
2150 repo.ui.progress('OBSEXC', None)
2135 else: 2151 else:
2136 rslts = [] 2152 rslts = []
2137 repo.ui.status("OBSEXC: encoding %i markers\n" % len(markers)) 2153 repo.ui.status("OBSEXC: encoding %i markers\n" % len(markers))
2138 remotedata = _pushkeyescape(markers).items() 2154 remotedata = _pushkeyescape(markers).items()
2139 totalbytes = sum(len(d) for k,d in remotedata) 2155 totalbytes = sum(len(d) for k,d in remotedata)