Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
( )
hg-reviewers |
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/subrepo.py (23 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
def archive(self, archiver, prefix, match=None, decode=True): | def archive(self, archiver, prefix, match=None, decode=True): | ||||
if match is not None: | if match is not None: | ||||
files = [f for f in self.files() if match(f)] | files = [f for f in self.files() if match(f)] | ||||
else: | else: | ||||
files = self.files() | files = self.files() | ||||
total = len(files) | total = len(files) | ||||
relpath = subrelpath(self) | relpath = subrelpath(self) | ||||
self.ui.progress(_('archiving (%s)') % relpath, 0, | progress = self.ui.makeprogress(_('archiving (%s)') % relpath, | ||||
unit=_('files'), total=total) | unit=_('files'), total=total) | ||||
for i, name in enumerate(files): | progress.update(0) | ||||
for name in files: | |||||
flags = self.fileflags(name) | flags = self.fileflags(name) | ||||
mode = 'x' in flags and 0o755 or 0o644 | mode = 'x' in flags and 0o755 or 0o644 | ||||
symlink = 'l' in flags | symlink = 'l' in flags | ||||
archiver.addfile(prefix + self._path + '/' + name, | archiver.addfile(prefix + self._path + '/' + name, | ||||
mode, symlink, self.filedata(name, decode)) | mode, symlink, self.filedata(name, decode)) | ||||
self.ui.progress(_('archiving (%s)') % relpath, i + 1, | progress.increment() | ||||
unit=_('files'), total=total) | progress.complete() | ||||
self.ui.progress(_('archiving (%s)') % relpath, None) | |||||
return total | return total | ||||
def walk(self, match): | def walk(self, match): | ||||
''' | ''' | ||||
walk recursively through the directory tree, finding all files | walk recursively through the directory tree, finding all files | ||||
matched by the match function | matched by the match function | ||||
''' | ''' | ||||
self._fetch(source, revision) | self._fetch(source, revision) | ||||
# Parse git's native archive command. | # Parse git's native archive command. | ||||
# This should be much faster than manually traversing the trees | # This should be much faster than manually traversing the trees | ||||
# and objects with many subprocess calls. | # and objects with many subprocess calls. | ||||
tarstream = self._gitcommand(['archive', revision], stream=True) | tarstream = self._gitcommand(['archive', revision], stream=True) | ||||
tar = tarfile.open(fileobj=tarstream, mode=r'r|') | tar = tarfile.open(fileobj=tarstream, mode=r'r|') | ||||
relpath = subrelpath(self) | relpath = subrelpath(self) | ||||
self.ui.progress(_('archiving (%s)') % relpath, 0, unit=_('files')) | progress = self.ui.makeprogress(_('archiving (%s)') % relpath, | ||||
for i, info in enumerate(tar): | unit=_('files')) | ||||
progress.update(0) | |||||
for info in tar: | |||||
if info.isdir(): | if info.isdir(): | ||||
continue | continue | ||||
if match and not match(info.name): | if match and not match(info.name): | ||||
continue | continue | ||||
if info.issym(): | if info.issym(): | ||||
data = info.linkname | data = info.linkname | ||||
else: | else: | ||||
data = tar.extractfile(info).read() | data = tar.extractfile(info).read() | ||||
archiver.addfile(prefix + self._path + '/' + info.name, | archiver.addfile(prefix + self._path + '/' + info.name, | ||||
info.mode, info.issym(), data) | info.mode, info.issym(), data) | ||||
total += 1 | total += 1 | ||||
self.ui.progress(_('archiving (%s)') % relpath, i + 1, | progress.increment() | ||||
unit=_('files')) | progress.complete() | ||||
self.ui.progress(_('archiving (%s)') % relpath, None) | |||||
return total | return total | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def cat(self, match, fm, fntemplate, prefix, **opts): | def cat(self, match, fm, fntemplate, prefix, **opts): | ||||
rev = self._state[1] | rev = self._state[1] | ||||
if match.anypats(): | if match.anypats(): | ||||
return 1 #No support for include/exclude yet | return 1 #No support for include/exclude yet |