Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 38385:3a7c33a2cc5e
subrepo: use progress helper
Differential Revision: https://phab.mercurial-scm.org/D3780
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sun, 17 Jun 2018 22:09:15 -0700 |
parents | c7eb9bce6041 |
children | 760cc5dc01e8 |
comparison
equal
deleted
inserted
replaced
38384:e5d87c69bbcb | 38385:3a7c33a2cc5e |
---|---|
331 files = [f for f in self.files() if match(f)] | 331 files = [f for f in self.files() if match(f)] |
332 else: | 332 else: |
333 files = self.files() | 333 files = self.files() |
334 total = len(files) | 334 total = len(files) |
335 relpath = subrelpath(self) | 335 relpath = subrelpath(self) |
336 self.ui.progress(_('archiving (%s)') % relpath, 0, | 336 progress = self.ui.makeprogress(_('archiving (%s)') % relpath, |
337 unit=_('files'), total=total) | 337 unit=_('files'), total=total) |
338 for i, name in enumerate(files): | 338 progress.update(0) |
339 for name in files: | |
339 flags = self.fileflags(name) | 340 flags = self.fileflags(name) |
340 mode = 'x' in flags and 0o755 or 0o644 | 341 mode = 'x' in flags and 0o755 or 0o644 |
341 symlink = 'l' in flags | 342 symlink = 'l' in flags |
342 archiver.addfile(prefix + self._path + '/' + name, | 343 archiver.addfile(prefix + self._path + '/' + name, |
343 mode, symlink, self.filedata(name, decode)) | 344 mode, symlink, self.filedata(name, decode)) |
344 self.ui.progress(_('archiving (%s)') % relpath, i + 1, | 345 progress.increment() |
345 unit=_('files'), total=total) | 346 progress.complete() |
346 self.ui.progress(_('archiving (%s)') % relpath, None) | |
347 return total | 347 return total |
348 | 348 |
349 def walk(self, match): | 349 def walk(self, match): |
350 ''' | 350 ''' |
351 walk recursively through the directory tree, finding all files | 351 walk recursively through the directory tree, finding all files |
1638 # This should be much faster than manually traversing the trees | 1638 # This should be much faster than manually traversing the trees |
1639 # and objects with many subprocess calls. | 1639 # and objects with many subprocess calls. |
1640 tarstream = self._gitcommand(['archive', revision], stream=True) | 1640 tarstream = self._gitcommand(['archive', revision], stream=True) |
1641 tar = tarfile.open(fileobj=tarstream, mode=r'r|') | 1641 tar = tarfile.open(fileobj=tarstream, mode=r'r|') |
1642 relpath = subrelpath(self) | 1642 relpath = subrelpath(self) |
1643 self.ui.progress(_('archiving (%s)') % relpath, 0, unit=_('files')) | 1643 progress = self.ui.makeprogress(_('archiving (%s)') % relpath, |
1644 for i, info in enumerate(tar): | 1644 unit=_('files')) |
1645 progress.update(0) | |
1646 for info in tar: | |
1645 if info.isdir(): | 1647 if info.isdir(): |
1646 continue | 1648 continue |
1647 if match and not match(info.name): | 1649 if match and not match(info.name): |
1648 continue | 1650 continue |
1649 if info.issym(): | 1651 if info.issym(): |
1651 else: | 1653 else: |
1652 data = tar.extractfile(info).read() | 1654 data = tar.extractfile(info).read() |
1653 archiver.addfile(prefix + self._path + '/' + info.name, | 1655 archiver.addfile(prefix + self._path + '/' + info.name, |
1654 info.mode, info.issym(), data) | 1656 info.mode, info.issym(), data) |
1655 total += 1 | 1657 total += 1 |
1656 self.ui.progress(_('archiving (%s)') % relpath, i + 1, | 1658 progress.increment() |
1657 unit=_('files')) | 1659 progress.complete() |
1658 self.ui.progress(_('archiving (%s)') % relpath, None) | |
1659 return total | 1660 return total |
1660 | 1661 |
1661 | 1662 |
1662 @annotatesubrepoerror | 1663 @annotatesubrepoerror |
1663 def cat(self, match, fm, fntemplate, prefix, **opts): | 1664 def cat(self, match, fm, fntemplate, prefix, **opts): |