[PATCH V2] fileset: add "subrepo" fileset symbol
Angel Ezquerra
angel.ezquerra at gmail.com
Wed Mar 28 17:15:17 CDT 2012
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1332447135 -3600
# Node ID 77bd9f83cea1533f355b590f4d4fcec2cb09c641
# Parent ac4a19fe5d9a583639fde43fe9183553f946bc4c
fileset: add "subrepo" fileset symbol
This new fileset symbol returns a list of subrepos whose path
matches 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.
diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -6,6 +6,7 @@
# GNU General Public License version 2 or any later version.
import parser, error, util, merge, re
+import match as matchmod
from i18n import _
elements = {
@@ -175,6 +176,27 @@
s = mctx.status()[6]
return [f for f in mctx.subset if f in s]
+def subrepo(mctx, x):
+ """``subrepo([pattern])``
+ Subrepository that is modified and matches the selected 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 glob pattern or no arguments"))
+
+ 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]
+
def func(mctx, a, b):
if a[0] == 'symbol' and a[1] in symbols:
return symbols[a[1]](mctx, b)
@@ -376,6 +398,7 @@
'symlink': symlink,
'unknown': unknown,
'unresolved': unresolved,
+ 'subrepo': subrepo,
}
methods = {
More information about the Mercurial-devel
mailing list