obsolete: add 'obsolete' keyword
The obsolete keyword displays the node status among 'stable',
'unstable', 'suspended', 'extinct'.
--- 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')
--- a/tests/test-obsolete.t Thu Jun 21 19:58:57 2012 +0200
+++ b/tests/test-obsolete.t Fri Jun 22 18:04:43 2012 +0200
@@ -111,6 +111,23 @@
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