Mercurial > hg-stable
changeset 38412:65d1d7da63d1
convert: use progress helper
Differential Revision: https://phab.mercurial-scm.org/D3807
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 18 Jun 2018 15:05:52 -0700 |
parents | 76a08cec029d |
children | 164306d3f4b4 |
files | hgext/convert/convcmd.py hgext/convert/subversion.py |
diffstat | 2 files changed, 16 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/convcmd.py Mon Jun 18 14:59:53 2018 -0700 +++ b/hgext/convert/convcmd.py Mon Jun 18 15:05:52 2018 -0700 @@ -143,13 +143,11 @@ def __init__(self, ui, source, filecount): self.ui = ui self.source = source - self.filecount = filecount - self.retrieved = 0 + self.progress = ui.makeprogress(_('getting files'), unit=_('files'), + total=filecount) def getfile(self, file, rev): - self.retrieved += 1 - self.ui.progress(_('getting files'), self.retrieved, - item=file, total=self.filecount, unit=_('files')) + self.progress.increment(item=file) return self.source.getfile(file, rev) def targetfilebelongstosource(self, targetfilename): @@ -159,7 +157,7 @@ return self.source.lookuprev(rev) def close(self): - self.ui.progress(_('getting files'), None) + self.progress.complete() class converter(object): def __init__(self, ui, source, dest, revmapfile, opts): @@ -238,6 +236,8 @@ known = set() parents = {} numcommits = self.source.numcommits() + progress = self.ui.makeprogress(_('scanning'), unit=_('revisions'), + total=numcommits) while visit: n = visit.pop(0) if n in known: @@ -247,14 +247,13 @@ if m == SKIPREV or self.dest.hascommitfrommap(m): continue known.add(n) - self.ui.progress(_('scanning'), len(known), unit=_('revisions'), - total=numcommits) + progress.update(len(known)) commit = self.cachecommit(n) parents[n] = [] for p in commit.parents: parents[n].append(p) visit.append(p) - self.ui.progress(_('scanning'), None) + progress.complete() return parents @@ -510,6 +509,8 @@ c = None self.ui.status(_("converting...\n")) + progress = self.ui.makeprogress(_('converting'), + unit=_('revisions'), total=len(t)) for i, c in enumerate(t): num -= 1 desc = self.commitcache[c].desc @@ -520,10 +521,9 @@ # uses is 'utf-8' self.ui.status("%d %s\n" % (num, recode(desc))) self.ui.note(_("source: %s\n") % recode(c)) - self.ui.progress(_('converting'), i, unit=_('revisions'), - total=len(t)) + progress.update(i) self.copy(c) - self.ui.progress(_('converting'), None) + progress.complete() if not self.ui.configbool('convert', 'skiptags'): tags = self.source.gettags()
--- a/hgext/convert/subversion.py Mon Jun 18 14:59:53 2018 -0700 +++ b/hgext/convert/subversion.py Mon Jun 18 15:05:52 2018 -0700 @@ -750,9 +750,10 @@ self.module = new_module self.reparent(self.module) + progress = self.ui.makeprogress(_('scanning paths'), unit=_('paths'), + total=len(paths)) for i, (path, ent) in enumerate(paths): - self.ui.progress(_('scanning paths'), i, item=path, - total=len(paths), unit=_('paths')) + progress.update(i, item=path) entrypath = self.getrelpath(path) kind = self._checkpath(entrypath, revnum) @@ -838,7 +839,7 @@ copytopath = self.getrelpath(copytopath) copies[self.recode(copytopath)] = self.recode(childpath) - self.ui.progress(_('scanning paths'), None) + progress.complete() changed.update(removed) return (list(changed), removed, copies)