revset: rename tagged() to tag() and allow it to take an optional tag name
authorAugie Fackler <durin42@gmail.com>
Sun, 10 Oct 2010 12:41:36 -0500
changeset 12715 33820dccbea4
parent 12714 f5178fbcd197
child 12716 c7e619e30ba3
revset: rename tagged() to tag() and allow it to take an optional tag name
mercurial/help/revsets.txt
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/help/revsets.txt	Sun Oct 10 12:40:25 2010 -0500
+++ b/mercurial/help/revsets.txt	Sun Oct 10 12:41:36 2010 -0500
@@ -151,8 +151,8 @@
   - ``user`` for user name (``author`` can be used as an alias),
   - ``date`` for the commit date
 
-``tagged()``
-  Changeset is tagged.
+``tag(name)``
+  The specified tag by name, or all tagged revisions if no name is given.
 
 ``user(string)``
   User name is string.
--- a/mercurial/revset.py	Sun Oct 10 12:40:25 2010 -0500
+++ b/mercurial/revset.py	Sun Oct 10 12:41:36 2010 -0500
@@ -467,10 +467,15 @@
     o = set([cl.rev(r) for r in repo.changelog.nodesbetween(o, revs)[0]])
     return [r for r in subset if r in o]
 
-def tagged(repo, subset, x):
-    getargs(x, 0, 0, _("tagged takes no arguments"))
+def tag(repo, subset, x):
+    args = getargs(x, 0, 1, _("tag takes one or no arguments"))
     cl = repo.changelog
-    s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip'])
+    if args:
+        tn = getstring(args[0],
+                       _('the argument to tag must be a string'))
+        s = set([cl.rev(n) for t, n in repo.tagslist() if t == tn])
+    else:
+        s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip'])
     return [r for r in subset if r in s]
 
 symbols = {
@@ -505,7 +510,8 @@
     "reverse": reverse,
     "roots": roots,
     "sort": sort,
-    "tagged": tagged,
+    "tag": tag,
+    "tagged": tag,
     "user": author,
 }
 
--- a/tests/test-revset.t	Sun Oct 10 12:40:25 2010 -0500
+++ b/tests/test-revset.t	Sun Oct 10 12:41:36 2010 -0500
@@ -287,6 +287,12 @@
   4
   $ log 'tagged()'
   6
+  $ log 'tag()'
+  6
+  $ log 'tag(1.0)'
+  6
+  $ log 'tag(tip)'
+  9
   $ log 'user(bob)'
   2