Commits

Patrick Mézard committed eda6491

obsolete: add 'obsolete' keyword

The obsolete keyword displays the node status among 'stable',
'unstable', 'suspended', 'extinct'.

Comments (0)

Files changed (2)

 from mercurial.lock import release
 from mercurial import localrepo
 from mercurial import cmdutil
+from mercurial import templatekw
 
 try:
     from mercurial.localrepo import storecache
     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
 ############################
     revset.symbols["obsparents"] = revsetobsparents
     revset.symbols["obsancestors"] = revsetobsancestors
 
+    templatekw.keywords['obsolete'] = obsoletekw
 
     try:
         rebase = extensions.find('rebase')

tests/test-obsolete.t

   5
   - a7a6f2b5d8a5
 
+Test obsolete keyword
+
+  $ hg glog --template '{rev}:{node|short}@{branch}({obsolete}/{phase}) {desc|firstline}\n' \
+  >   --hidden
+  @  5:a7a6f2b5d8a5@default(unstable/secret) add d
+  |
+  | o  4:725c380fe99b@default(stable/draft) add obsol_c'
+  | |
+  o |  3:0d3f46688ccc@default(suspended/secret) add obsol_c
+  |/
+  | o  2:4538525df7e2@default(extinct/secret) add c
+  |/
+  o  1:7c3bad9141dc@default(stable/draft) add b
+  |
+  o  0:1f0dee641bb7@default(stable/public) add a
+  
+
 Test communication of obsolete relation with a compatible client
 
   $ hg init ../other-new