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)

hgext/obsolete.py

 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.