diff hgext/obsolete.py @ 299:eda6491ca269

obsolete: add 'obsolete' keyword The obsolete keyword displays the node status among 'stable', 'unstable', 'suspended', 'extinct'.
author Patrick Mezard <patrick@mezard.eu>
date Fri, 22 Jun 2012 18:04:43 +0200
parents f597421662f7
children 3b1f326878e5
line wrap: on
line diff
--- a/hgext/obsolete.py	Thu Jun 21 19:58:57 2012 +0200
+++ b/hgext/obsolete.py	Fri Jun 22 18:04:43 2012 +0200
@@ -101,6 +101,7 @@
 from mercurial.lock import release
 from mercurial import localrepo
 from mercurial import cmdutil
+from mercurial import templatekw
 
 try:
     from mercurial.localrepo import storecache
@@ -215,6 +216,21 @@
     return [r for r in subset if r in cs]
 
 
+### template keywords
+#####################
+
+def obsoletekw(repo, ctx, templ, **args):
+    """:obsolete: String. The obsolescence level of the node, could be
+    ``stable``, ``unstable``, ``suspended`` or ``extinct``.
+    """
+    rev = ctx.rev()
+    if rev in repo._extinctset:
+        return 'extinct'
+    if rev in repo._suspendedset:
+        return 'suspended'
+    if rev in repo._unstableset:
+        return 'unstable'
+    return 'stable'
 
 ### Other Extension compat
 ############################
@@ -310,6 +326,7 @@
     revset.symbols["obsparents"] = revsetobsparents
     revset.symbols["obsancestors"] = revsetobsancestors
 
+    templatekw.keywords['obsolete'] = obsoletekw
 
     try:
         rebase = extensions.find('rebase')