Mercurial > hg
changeset 16443:9e02e032b522
fileset: add "subrepo" fileset symbol
This new fileset symbol returns a list of subrepos whose paths match a given
pattern. If the argument has no pattern type set, an exact
match is performed.
If no argument is passed, return a list of all subrepos.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Thu, 22 Mar 2012 21:12:15 +0100 |
parents | 9181188ffb5b |
children | 432f198600c6 |
files | mercurial/fileset.py |
diffstat | 1 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/fileset.py Sun Apr 15 23:47:46 2012 -0700 +++ b/mercurial/fileset.py Thu Mar 22 21:12:15 2012 +0100 @@ -358,6 +358,28 @@ s.append(f) return s +def subrepo(mctx, x): + """``subrepo([pattern])`` + Subrepositories whose paths match the given pattern. + """ + # i18n: "subrepo" is a keyword + getargs(x, 0, 1, _("subrepo takes at most one argument")) + ctx = mctx.ctx + sstate = ctx.substate + if x: + pat = getstring(x, _("subrepo requires a pattern or no arguments")) + + import match as matchmod # avoid circular import issues + fast = not matchmod.patkind(pat) + if fast: + def m(s): + return (s == pat) + else: + m = matchmod.match(ctx._repo.root, '', [pat], ctx=ctx) + return [sub for sub in sstate if m(sub)] + else: + return [sub for sub in sstate] + symbols = { 'added': added, 'binary': binary, @@ -376,6 +398,7 @@ 'symlink': symlink, 'unknown': unknown, 'unresolved': unresolved, + 'subrepo': subrepo, } methods = {