Mercurial > evolve
diff hgext/evolve.py @ 1034:5fd28e46e8f5
evolve: move OBSEXC progress in a dedicated function
This will help use to rework them.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 08 Aug 2014 17:10:31 -0700 |
parents | 908273755215 |
children | 59bc29c84ce0 |
line wrap: on
line diff
--- a/hgext/evolve.py Fri Aug 08 16:48:38 2014 -0700 +++ b/hgext/evolve.py Fri Aug 08 17:10:31 2014 -0700 @@ -2229,6 +2229,9 @@ message = 'OBSEXC: ' + message ui.status(message) +def obsexcprg(ui, *args, **kwargs): + ui.progress('OBSEXC', *args, **kwargs) + @command('debugobsoleterelevant', [], @@ -2307,8 +2310,7 @@ return len(self.getvalue()) def read(self, size): - self.ui.progress('OBSEXC', self.tell(), unit="bytes", - total=self.length) + obsexcprg(self.ui, self.tell(), unit="bytes", total=self.length) return StringIO.read(self, size) def __iter__(self): @@ -2400,7 +2402,7 @@ % (len(markers), len(obsdata.getvalue()))) bundler.newpart('EVOLVE:B2X:OBSMARKERV1', data=obsdata) def callback(op): - repo.ui.progress('OBSEXC', None) + obsexcprg(repo.ui, None) obsexcmsg(repo.ui, "DONE\n") return callback bundle2partsgenerators.append(_pushb2phases) @@ -2486,7 +2488,7 @@ op = bundle2.processbundle(pushop.repo, reply) except bundle2.UnknownPartError, exc: raise util.Abort('missing support for %s' % exc) - repo.ui.progress('OBSEXC', None) + obsexcprg(repo.ui, None) elif remote.capable('_evoext_pushobsmarkers_0'): obsdata = pushobsmarkerStringIO() _encodemarkersstream(obsdata, markers) @@ -2495,7 +2497,7 @@ obsexcmsg(repo.ui, "pushing %i markers (%i bytes)\n" % (len(markers), len(obsdata.getvalue()))) remote.evoext_pushobsmarkers_0(obsdata) - repo.ui.progress('OBSEXC', None) + obsexcprg(repo.ui, None) else: rslts = [] remotedata = _pushkeyescape(markers).items() @@ -2504,13 +2506,13 @@ obsexcmsg(repo.ui, "pushing %i markers in %i pushkey payload (%i bytes)\n" % (len(markers), len(remotedata), totalbytes)) for key, data in remotedata: - repo.ui.progress('OBSEXC', sentbytes, item=key, unit="bytes", - total=totalbytes) + obsexcprg(repo.ui, sentbytes, item=key, unit="bytes", + total=totalbytes) rslts.append(remote.pushkey('obsolete', key, '', data)) sentbytes += len(data) - repo.ui.progress('OBSEXC', sentbytes, item=key, unit="bytes", - total=totalbytes) - repo.ui.progress('OBSEXC', None) + obsexcprg(repo.ui, sentbytes, item=key, unit="bytes", + total=totalbytes) + obsexcprg(repo.ui, None) if [r for r in rslts if not r]: msg = _('failed to push some obsolete markers!\n') repo.ui.warn(msg) @@ -2572,13 +2574,13 @@ length = int(length) data = StringIO() current = 0 - op.ui.progress('OBSEXC', current, unit="bytes", total=length) + obsexcprg(op.repo.ui, current, unit="bytes", total=length) while current < length: readsize = min(length-current, 4096) data.write(inpart.read(readsize)) current += readsize - op.ui.progress('OBSEXC', current, unit="bytes", total=length) - op.ui.progress('OBSEXC', None) + obsexcprg(op.repo.ui, current, unit="bytes", total=length) + obsexcprg(op.repo.ui, None) obsdata = data.getvalue() totalsize = len(obsdata) old = len(op.repo.obsstore._all) @@ -2732,13 +2734,13 @@ current = 0 data = StringIO() ui = self.ui - ui.progress('OBSEXC', current, unit="bytes", total=length) + obsexcprg(ui, 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) + obsexcprg(ui, current, unit="bytes", total=length) + obsexcprg(ui, None) data.seek(0) return data