changeset 30712:5dde81de1e6d

templatekw: add a "troubles" template keyword The "troubles" template keyword returns a list of evolution troubles. It is EXPERIMENTAL, as anything else related to changeset evolution. Test it in test-obsolete.t which has troubled changesets.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Fri, 06 Jan 2017 13:50:16 +0100
parents c03627d87d9d
children 6d0b1a69f98c
files mercurial/templatekw.py tests/test-obsolete.t
diffstat 2 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Fri Jan 06 15:48:22 2017 +0100
+++ b/mercurial/templatekw.py	Fri Jan 06 13:50:16 2017 +0100
@@ -595,5 +595,13 @@
     """Integer. The width of the current terminal."""
     return repo.ui.termwidth()
 
+@templatekeyword('troubles')
+def showtroubles(**args):
+    """List of strings. Evolution troubles affecting the changeset.
+
+    (EXPERIMENTAL)
+    """
+    return showlist('trouble', args['ctx'].troubles(), **args)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = keywords.values()
--- a/tests/test-obsolete.t	Fri Jan 06 15:48:22 2017 +0100
+++ b/tests/test-obsolete.t	Fri Jan 06 13:50:16 2017 +0100
@@ -3,7 +3,7 @@
   > # public changeset are not obsolete
   > publish=false
   > [ui]
-  > logtemplate="{rev}:{node|short} ({phase}) [{tags} {bookmarks}] {desc|firstline}\n"
+  > logtemplate="{rev}:{node|short} ({phase}{if(troubles, ' {troubles}')}) [{tags} {bookmarks}] {desc|firstline}\n"
   > EOF
   $ mkcommit() {
   >    echo "$1" > "$1"
@@ -203,7 +203,7 @@
 
   $ hg --hidden phase --public 2
   $ hg log -G
-  @  5:5601fb93a350 (draft) [tip ] add new_3_c
+  @  5:5601fb93a350 (draft bumped) [tip ] add new_3_c
   |
   | o  2:245bde4270cd (public) [ ] add original_c
   |/
@@ -220,7 +220,7 @@
 the public changeset
 
   $ hg log --hidden -r 'bumped()'
-  5:5601fb93a350 (draft) [tip ] add new_3_c
+  5:5601fb93a350 (draft bumped) [tip ] add new_3_c
 
 And that we can't push bumped changeset
 
@@ -485,7 +485,7 @@
   phases: 3 draft
   unstable: 1 changesets
   $ hg log -G -r '::unstable()'
-  @  5:cda648ca50f5 (draft) [tip ] add original_e
+  @  5:cda648ca50f5 (draft unstable) [tip ] add original_e
   |
   x  4:94b33453f93b (draft) [ ] add original_d
   |
@@ -527,7 +527,7 @@
   2:245bde4270cd (public) [ ] add original_c
   3:6f9641995072 (draft) [ ] add n3w_3_c
   4:94b33453f93b (draft) [ ] add original_d
-  5:cda648ca50f5 (draft) [tip ] add original_e
+  5:cda648ca50f5 (draft unstable) [tip ] add original_e
   $ hg push ../tmpf -f # -f because be push unstable too
   pushing to ../tmpf
   searching for changes
@@ -548,7 +548,7 @@
 Do not warn about new head when the new head is a successors of a remote one
 
   $ hg log -G
-  @  5:cda648ca50f5 (draft) [tip ] add original_e
+  @  5:cda648ca50f5 (draft unstable) [tip ] add original_e
   |
   x  4:94b33453f93b (draft) [ ] add original_d
   |
@@ -810,6 +810,11 @@
   summary:     add babar
   
 
+test the "troubles" templatekw
+
+  $ hg log -r 'bumped() and unstable()'
+  7:50c51b361e60 (draft unstable bumped) [ ] add babar
+
 Test incoming/outcoming with changesets obsoleted remotely, known locally
 ===============================================================================