This new revset symbol finds those revisions in which any subrepo whose path
matches a given glob pattern were modified (e.g. "subrepo(my*repo)").
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
@@ -5,7 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-import re
+import re, fnmatch
import parser, util, error, discovery, hbisect, phases
import node as nodemod
import bookmarks as bookmarksmod
@@ -935,6 +935,28 @@
l.sort()
return [e[-1] for e in l]
+def subrepo(repo, subset, x):
+ """``subrepo([path])``
+ Find revisions where the selected subrepo has been modified.
+ With no argument, find revisions where any subrepo has been modified.
+ """
+ # i18n: "subrepo" is a keyword
+ if x:
+ pat = encoding.lower(
+ getstring(x, _("subrepo requires a string or no arguments")))
+
+ def matchpat(pat, subs):
+ for sub in subs:
+ if fnmatch.fnmatch(sub, pat):
+ return True
+ return False
+
+ # Note that fnmatch, which is used in matchpat, caches patterns so
+ # repeatedly calling fnmatch.fnmatch with the same pattern is efficient
+ return [r for r in subset if matchpat(pat, repo[r].substate)]
+ 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.
@@ -1019,6 +1041,7 @@
"roots": roots,
"sort": sort,
"secret": secret,
+ "subrepo": subrepo,
"tag": tag,
"tagged": tagged,
"user": user,