# HG changeset patch # User Martin von Zweigbergk # Date 1529298555 25200 # Node ID 3a7c33a2cc5e8e909bc6c27fe8a31a6fc0ee8d78 # Parent e5d87c69bbcba2df8a97b7298f71a8cba5f2a853 subrepo: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3780 diff -r e5d87c69bbcb -r 3a7c33a2cc5e mercurial/subrepo.py --- a/mercurial/subrepo.py Sun Jun 17 22:05:54 2018 -0700 +++ b/mercurial/subrepo.py Sun Jun 17 22:09:15 2018 -0700 @@ -333,17 +333,17 @@ files = self.files() total = len(files) relpath = subrelpath(self) - self.ui.progress(_('archiving (%s)') % relpath, 0, - unit=_('files'), total=total) - for i, name in enumerate(files): + progress = self.ui.makeprogress(_('archiving (%s)') % relpath, + unit=_('files'), total=total) + progress.update(0) + for name in files: flags = self.fileflags(name) mode = 'x' in flags and 0o755 or 0o644 symlink = 'l' in flags archiver.addfile(prefix + self._path + '/' + name, mode, symlink, self.filedata(name, decode)) - self.ui.progress(_('archiving (%s)') % relpath, i + 1, - unit=_('files'), total=total) - self.ui.progress(_('archiving (%s)') % relpath, None) + progress.increment() + progress.complete() return total def walk(self, match): @@ -1640,8 +1640,10 @@ tarstream = self._gitcommand(['archive', revision], stream=True) tar = tarfile.open(fileobj=tarstream, mode=r'r|') relpath = subrelpath(self) - self.ui.progress(_('archiving (%s)') % relpath, 0, unit=_('files')) - for i, info in enumerate(tar): + progress = self.ui.makeprogress(_('archiving (%s)') % relpath, + unit=_('files')) + progress.update(0) + for info in tar: if info.isdir(): continue if match and not match(info.name): @@ -1653,9 +1655,8 @@ archiver.addfile(prefix + self._path + '/' + info.name, info.mode, info.issym(), data) total += 1 - self.ui.progress(_('archiving (%s)') % relpath, i + 1, - unit=_('files')) - self.ui.progress(_('archiving (%s)') % relpath, None) + progress.increment() + progress.complete() return total