# HG changeset patch # User Martin von Zweigbergk # Date 2018-06-18 22:14:39 # Node ID 164306d3f4b4f50d961d6b94cd52de39178ddc67 # Parent 65d1d7da63d14b0efc4ac1fa165fe67ab8fc244d largefiles: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3808 diff --git a/hgext/largefiles/basestore.py b/hgext/largefiles/basestore.py --- a/hgext/largefiles/basestore.py +++ b/hgext/largefiles/basestore.py @@ -62,9 +62,10 @@ class basestore(object): at = 0 available = self.exists(set(hash for (_filename, hash) in files)) + progress = ui.makeprogress(_('getting largefiles'), unit=_('files'), + total=len(files)) for filename, hash in files: - ui.progress(_('getting largefiles'), at, unit=_('files'), - total=len(files)) + progress.update(at) at += 1 ui.note(_('getting %s:%s\n') % (filename, hash)) @@ -79,7 +80,7 @@ class basestore(object): else: missing.append(filename) - ui.progress(_('getting largefiles'), None) + progress.complete() return (success, missing) def _gethash(self, filename, hash): diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py --- a/hgext/largefiles/lfcommands.py +++ b/hgext/largefiles/lfcommands.py @@ -118,12 +118,14 @@ def lfconvert(ui, src, dest, *pats, **op matcher = None lfiletohash = {} + progress = ui.makeprogress(_('converting revisions'), + unit=_('revisions'), + total=rsrc['tip'].rev()) for ctx in ctxs: - ui.progress(_('converting revisions'), ctx.rev(), - unit=_('revisions'), total=rsrc['tip'].rev()) + progress.update(ctx.rev()) _lfconvert_addchangeset(rsrc, rdst, ctx, revmap, lfiles, normalfiles, matcher, size, lfiletohash) - ui.progress(_('converting revisions'), None) + progress.complete() if rdst.wvfs.exists(lfutil.shortname): rdst.wvfs.rmtree(lfutil.shortname) @@ -368,9 +370,10 @@ def uploadlfiles(ui, rsrc, rdst, files): files = [h for h in files if not retval[h]] ui.debug("%d largefiles need to be uploaded\n" % len(files)) + progress = ui.makeprogress(_('uploading largefiles'), unit=_('files'), + total=len(files)) for hash in files: - ui.progress(_('uploading largefiles'), at, unit=_('files'), - total=len(files)) + progress.update(at) source = lfutil.findfile(rsrc, hash) if not source: raise error.Abort(_('largefile %s missing from store' @@ -378,7 +381,7 @@ def uploadlfiles(ui, rsrc, rdst, files): # XXX check for errors here store.put(source, hash) at += 1 - ui.progress(_('uploading largefiles'), None) + progress.complete() def verifylfiles(ui, repo, all=False, contents=False): '''Verify that every largefile revision in the current changeset diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -501,9 +501,10 @@ def getlfilestoupdate(oldstandins, newst return filelist def getlfilestoupload(repo, missing, addfunc): + progress = repo.ui.makeprogress(_('finding outgoing largefiles'), + unit=_('revisions'), total=len(missing)) for i, n in enumerate(missing): - repo.ui.progress(_('finding outgoing largefiles'), i, - unit=_('revisions'), total=len(missing)) + progress.update(i) parents = [p for p in repo[n].parents() if p != node.nullid] oldlfstatus = repo.lfstatus @@ -530,7 +531,7 @@ def getlfilestoupload(repo, missing, add for fn in files: if isstandin(fn) and fn in ctx: addfunc(fn, readasstandin(ctx[fn])) - repo.ui.progress(_('finding outgoing largefiles'), None) + progress.complete() def updatestandinsbymatch(repo, match): '''Update standins in the working directory according to specified match