661dbd42f386

Merge.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 14 Mar 2012 17:13:42 -0400
parents e16ee632ce6f (diff) 5faf9b0ae984 (current diff)
children 1cb3af183d2f
branches/tags (none)
files prompt.py

Changes

--- a/docs/wiki/documentation/keywords/index.mdown	Tue Jul 05 14:19:52 2011 -0500
+++ b/docs/wiki/documentation/keywords/index.mdown	Wed Mar 14 17:13:42 2012 -0400
@@ -157,6 +157,9 @@
 ##tags##
 :   Display the tags of the current parent, separated by a space.
     
+    |quiet
+        Display the tags of the current parent, excluding the tag "tip".
+
     |SEP
     :   Display the tags of the current parent, separated by `SEP`.
 
--- a/prompt.py	Tue Jul 05 14:19:52 2011 -0500
+++ b/prompt.py	Wed Mar 14 17:13:42 2012 -0400
@@ -1,7 +1,5 @@
 #!/usr/bin/env python
 
-from __future__ import with_statement
-
 '''get repository information for use in a shell prompt
 
 Take a string, parse any special variables inside, and output the result.
@@ -10,6 +8,8 @@
 a shell prompt.
 '''
 
+from __future__ import with_statement
+
 import re
 import os
 import subprocess
@@ -18,6 +18,13 @@
 from mercurial import extensions, commands, cmdutil, help
 from mercurial.node import hex, short
 
+# `revrange' has been moved into module `scmutil' since v1.9.
+try :
+    from mercurial import scmutil
+    revrange = scmutil.revrange
+except :
+    revrange = cmdutil.revrange
+
 CACHE_PATH = ".hg/prompt/cache"
 CACHE_TIMEOUT = timedelta(minutes=15)
 
@@ -137,7 +144,7 @@
     def _count(m):
         g = m.groups()
         query = [g[1][1:]] if g[1] else ['all()']
-        return _with_groups(g, str(len(cmdutil.revrange(repo, query))))
+        return _with_groups(g, str(len(revrange(repo, query))))
 
     def _node(m):
         g = m.groups()
@@ -309,9 +316,13 @@
     def _tags(m):
         g = m.groups()
 
-        sep = g[1][1:] if g[1] else ' '
+        sep = g[2][1:] if g[2] else ' '
         tags = repo[None].tags()
 
+        quiet = _get_filter('quiet', g)
+        if quiet:
+            tags = filter(lambda tag: tag != 'tip', tags)
+
         return _with_groups(g, sep.join(tags)) if tags else ''
 
     def _task(m):
@@ -385,7 +396,10 @@
             '(\|modified)'
             '|(\|unknown)'
             ')*': _status,
-        'tags(\|[^%s]*?)?' % brackets[-1]: _tags,
+        'tags(?:' +
+            '(\|quiet)' +
+            '|(\|[^%s]*?)' % brackets[-1] +
+            ')*': _tags,
         'task': _task,
         'tip(?:'
             '(\|node)'
@@ -598,6 +612,9 @@
 tags
      Display the tags of the current parent, separated by a space.
 
+     |quiet
+         Display the tags of the current parent, excluding the tag "tip".
+
      |SEP
          Display the tags of the current parent, separated by `SEP`.