Mercurial > public > mercurial-scm > hg-stable
diff mercurial/subrepo.py @ 17108:1894dac619de
subrepo: propagate matcher to subrepos when archiving
Add a match object to subrepo.archive(). This will allow the -X and -I
options to be honored inside subrepos when archiving. They formerly
only affect the top level repo.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 16 Jun 2012 22:34:06 -0400 |
parents | ab4644c3064f |
children | f7152a0d90df |
line wrap: on
line diff
--- a/mercurial/subrepo.py Mon Jun 18 22:45:21 2012 -0400 +++ b/mercurial/subrepo.py Sat Jun 16 22:34:06 2012 -0400 @@ -8,7 +8,7 @@ import errno, os, re, xml.dom.minidom, shutil, posixpath import stat, subprocess, tarfile from i18n import _ -import config, scmutil, util, node, error, cmdutil, bookmarks +import config, scmutil, util, node, error, cmdutil, bookmarks, match as matchmod hg = None propertycache = util.propertycache @@ -351,8 +351,11 @@ """return file flags""" return '' - def archive(self, ui, archiver, prefix): - files = self.files() + def archive(self, ui, archiver, prefix, match=None): + if match is not None: + files = [f for f in self.files() if match(f)] + else: + files = self.files() total = len(files) relpath = subrelpath(self) ui.progress(_('archiving (%s)') % relpath, 0, @@ -445,15 +448,16 @@ self._repo.ui.warn(_('warning: error "%s" in subrepository "%s"\n') % (inst, subrelpath(self))) - def archive(self, ui, archiver, prefix): + def archive(self, ui, archiver, prefix, match=None): self._get(self._state + ('hg',)) - abstractsubrepo.archive(self, ui, archiver, prefix) + abstractsubrepo.archive(self, ui, archiver, prefix, match) rev = self._state[1] ctx = self._repo[rev] for subpath in ctx.substate: s = subrepo(ctx, subpath) - s.archive(ui, archiver, os.path.join(prefix, self._path)) + submatch = matchmod.narrowmatcher(subpath, match) + s.archive(ui, archiver, os.path.join(prefix, self._path), submatch) def dirty(self, ignoreupdate=False): r = self._state[1] @@ -1205,7 +1209,7 @@ else: os.remove(path) - def archive(self, ui, archiver, prefix): + def archive(self, ui, archiver, prefix, match=None): source, revision = self._state if not revision: return @@ -1221,6 +1225,8 @@ for i, info in enumerate(tar): if info.isdir(): continue + if match and not match(info.name): + continue if info.issym(): data = info.linkname else: