[PATCH] revset: add "containssubrepo" revset symbol
Angel Ezquerra
angel.ezquerra at gmail.com
Tue Mar 27 22:48:25 UTC 2012
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1332447135 -3600
# Node ID f0dcf85a7c22699385092dce4d2740309336663b
# Parent c0ef704422740b8a978acdca8287546c5fd11057
revset: add "containssubrepo" revset symbol
This new revset symbol finds those revisions containing any subrepo whose path
matches a given pattern. If the argument has no pattern type set, an exact
match is performed.
If no argument is passed, find those revisions in which any subrepo was
modified.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -935,6 +935,33 @@
l.sort()
return [e[-1] for e in l]
+def containssubrepo(repo, subset, x):
+ """``containssubrepo([path])``
+ Find revisions containing a given subrepo.
+ With no argument, find revisions containing any subrepo.
+ """
+ # i18n: "containssubrepo" is a keyword
+ if x:
+ pat = getstring(x,
+ _("containssubrepo requires a string or no arguments"))
+
+ fast = not matchmod.patkind(pat)
+ if fast:
+ def matchsubpat(pat, ctx):
+ return pat in ctx.substate
+ else:
+ def matchsubpat(pat, ctx):
+ m = matchmod.match(repo.root, '', [pat], ctx=ctx)
+ for s in ctx.substate:
+ print s
+ if m(s):
+ return True
+ return False
+
+ return [r for r in subset if matchsubpat(pat, repo[r])]
+ else:
+ return [r for r in subset if repo[r].substate]
+
def tag(repo, subset, x):
"""``tag([name])``
The specified tag by name, or all tagged revisions if no name is given.
@@ -985,6 +1012,7 @@
"children": children,
"closed": closed,
"contains": contains,
+ "containssubrepo": containssubrepo,
"date": date,
"desc": desc,
"descendants": descendants,
More information about the Mercurial-devel
mailing list