comparison mercurial/revset.py @ 23836: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 9b1d3bac61a7
children 91dbb98b3513
comparison
equal deleted inserted replaced
23835:aa4a1672583e 23836:3fb61fcbc4e4
1175 """ 1175 """
1176 # i18n: "modifies" is a keyword 1176 # i18n: "modifies" is a keyword
1177 pat = getstring(x, _("modifies requires a pattern")) 1177 pat = getstring(x, _("modifies requires a pattern"))
1178 return checkstatus(repo, subset, pat, 0) 1178 return checkstatus(repo, subset, pat, 0)
1179 1179
1180 def named(repo, subset, x):
1181 """``named(namespace)``
1182 The changesets in a given namespace.
1183
1184 If `namespace` starts with `re:`, the remainder of the string is treated as
1185 a regular expression. To match a namespace that actually starts with `re:`,
1186 use the prefix `literal:`.
1187 """
1188 # i18n: "named" is a keyword
1189 args = getargs(x, 1, 1, _('named requires a namespace argument'))
1190
1191 ns = getstring(args[0],
1192 # i18n: "named" is a keyword
1193 _('the argument to named must be a string'))
1194 kind, pattern, matcher = _stringmatcher(ns)
1195 namespaces = set()
1196 if kind == 'literal':
1197 if pattern not in repo.names:
1198 raise util.Abort(_("namespace '%s' does not exist") % ns)
1199 namespaces.add(repo.names[pattern])
1200 else:
1201 for name, ns in repo.names.iteritems():
1202 if matcher(name):
1203 namespaces.add(ns)
1204 if not namespaces:
1205 raise util.Abort(_("no namespace exists that match '%s'")
1206 % pattern)
1207
1208 names = set()
1209 for ns in namespaces:
1210 for name in ns.listnames(repo):
1211 names.update(ns.nodes(repo, name))
1212
1213 names -= set([node.nullrev])
1214 return subset & names
1215
1180 def node_(repo, subset, x): 1216 def node_(repo, subset, x):
1181 """``id(string)`` 1217 """``id(string)``
1182 Revision non-ambiguously specified by the given hex string prefix. 1218 Revision non-ambiguously specified by the given hex string prefix.
1183 """ 1219 """
1184 # i18n: "id" is a keyword 1220 # i18n: "id" is a keyword
1815 "_matchfiles": _matchfiles, 1851 "_matchfiles": _matchfiles,
1816 "max": maxrev, 1852 "max": maxrev,
1817 "merge": merge, 1853 "merge": merge,
1818 "min": minrev, 1854 "min": minrev,
1819 "modifies": modifies, 1855 "modifies": modifies,
1856 "named": named,
1820 "obsolete": obsolete, 1857 "obsolete": obsolete,
1821 "only": only, 1858 "only": only,
1822 "origin": origin, 1859 "origin": origin,
1823 "outgoing": outgoing, 1860 "outgoing": outgoing,
1824 "p1": p1, 1861 "p1": p1,