Mercurial > hg > mercurial-source
changeset 23848:3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
This patch adds functionality for listing all changesets in a given namespace
via the revset language.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Tue, 13 Jan 2015 15:07:08 -0800 |
parents | aa4a1672583e |
children | 2b79d124a12f |
files | mercurial/revset.py |
diffstat | 1 files changed, 37 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1177,6 +1177,42 @@ pat = getstring(x, _("modifies requires a pattern")) return checkstatus(repo, subset, pat, 0) +def named(repo, subset, x): + """``named(namespace)`` + The changesets in a given namespace. + + If `namespace` starts with `re:`, the remainder of the string is treated as + a regular expression. To match a namespace that actually starts with `re:`, + use the prefix `literal:`. + """ + # i18n: "named" is a keyword + args = getargs(x, 1, 1, _('named requires a namespace argument')) + + ns = getstring(args[0], + # i18n: "named" is a keyword + _('the argument to named must be a string')) + kind, pattern, matcher = _stringmatcher(ns) + namespaces = set() + if kind == 'literal': + if pattern not in repo.names: + raise util.Abort(_("namespace '%s' does not exist") % ns) + namespaces.add(repo.names[pattern]) + else: + for name, ns in repo.names.iteritems(): + if matcher(name): + namespaces.add(ns) + if not namespaces: + raise util.Abort(_("no namespace exists that match '%s'") + % pattern) + + names = set() + for ns in namespaces: + for name in ns.listnames(repo): + names.update(ns.nodes(repo, name)) + + names -= set([node.nullrev]) + return subset & names + def node_(repo, subset, x): """``id(string)`` Revision non-ambiguously specified by the given hex string prefix. @@ -1817,6 +1853,7 @@ "merge": merge, "min": minrev, "modifies": modifies, + "named": named, "obsolete": obsolete, "only": only, "origin": origin,