Commits

Steve Losh committed 43b7fb8

Add the {closed} keyword.

Comments (0)

Files changed (2)

docs/wiki/documentation/keywords/index.mdown

 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]
 
     |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).
 
         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()
 
         'bookmark': _bookmark,
         'branch(\|quiet)?': _branch,
         'count(\|[^%s]*?)?' % brackets[-1]: _count,
+        'closed(\|quiet)?': _closed,
         'node(?:'
             '(\|short)'
             '|(\|merge)'
      |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).