43b7fb82d9a0

Add the {closed} keyword.
[view raw] [browse files]
author Steve Losh <steve@dwaiter.com>
date Mon, 05 Jul 2010 14:50:51 -0400
parents 34e96de049ab
children 645406a4e1fb
branches/tags (none)
files docs/wiki/documentation/keywords/index.mdown prompt.py

Changes

--- a/docs/wiki/documentation/keywords/index.mdown	Tue Jun 22 18:16:29 2010 -0400
+++ b/docs/wiki/documentation/keywords/index.mdown	Mon Jul 05 14:50:51 2010 -0400
@@ -1,11 +1,13 @@
 Keywords
 ========
 
-There a number of keywords available.  If you have any suggestions for more please [let me know][issues].
+There a number of keywords available.  If you have any suggestions for more
+please [let me know][issues].
 
 [issues]: http://bitbucket.org/sjl/issues
 
-Some of the keywords support filters.  These filters can be combined when it makes sense.  If in doubt, try it!
+Some of the keywords support filters.  These filters can be combined when it
+makes sense.  If in doubt, try it!
 
 [TOC]
 
@@ -18,6 +20,10 @@
     |quiet
     :   Display the current branch only if it is not the default branch.
 
+##closed##
+:   Display `X` if working on a closed branch (i.e. if committing now would
+    reopen the branch).
+
 ##count##
 :   Display the number of revisions in the given revset (the revset `all()`
     will be used if none is given).
--- a/prompt.py	Tue Jun 22 18:16:29 2010 -0400
+++ b/prompt.py	Mon Jul 05 14:50:51 2010 -0400
@@ -103,6 +103,20 @@
 
         return _with_groups(g, out) if out else ''
 
+    def _closed(m):
+        g = m.groups()
+
+        quiet = _get_filter('quiet', g)
+
+        p = repo[None].parents()[0]
+        pn = p.node()
+        branch = repo.dirstate.branch()
+        closed = (p.extra().get('close')
+                  and pn in repo.branchheads(branch, closed=True))
+        out = 'X' if (not quiet) and closed else ''
+
+        return _with_groups(g, out) if out else ''
+
     def _status(m):
         g = m.groups()
 
@@ -311,6 +325,7 @@
         'bookmark': _bookmark,
         'branch(\|quiet)?': _branch,
         'count(\|[^%s]*?)?' % brackets[-1]: _count,
+        'closed(\|quiet)?': _closed,
         'node(?:'
             '(\|short)'
             '|(\|merge)'
@@ -405,6 +420,10 @@
      |quiet
          Display the current branch only if it is not the default branch.
 
+closed
+     Display `X` if working on a closed branch (i.e. committing now would reopen
+     the branch).
+
 count
      Display the number of revisions in the given revset (the revset `all()`
      will be used if none is given).