changeset 12715:33820dccbea4

revset: rename tagged() to tag() and allow it to take an optional tag name
author Augie Fackler <durin42@gmail.com>
date Sun, 10 Oct 2010 12:41:36 -0500
parents f5178fbcd197
children c7e619e30ba3
files mercurial/help/revsets.txt mercurial/revset.py tests/test-revset.t
diffstat 3 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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