Patchwork [4,of,6,V5] templates: display evolution "troubles" in command line style

login
register
mail settings
Submitter Denis Laxalde
Date Jan. 6, 2017, 3:32 p.m.
Message ID <87399b8a6ae5a1c38c49.1483716747@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/18120/
State Accepted
Headers show

Comments

Denis Laxalde - Jan. 6, 2017, 3:32 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1483707052 -3600
#      Fri Jan 06 13:50:52 2017 +0100
# Node ID 87399b8a6ae5a1c38c4969d705a358ba17d7dffd
# Parent  bf1e87a41962c793ae1c0ce361cd79aac3f98f1c
# EXP-Topic evolve-ui
templates: display evolution "troubles" in command line style
Yuya Nishihara - Jan. 7, 2017, 8:52 a.m.
On Fri, 06 Jan 2017 16:32:27 +0100, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1483707052 -3600
> #      Fri Jan 06 13:50:52 2017 +0100
> # Node ID 87399b8a6ae5a1c38c4969d705a358ba17d7dffd
> # Parent  bf1e87a41962c793ae1c0ce361cd79aac3f98f1c
> # EXP-Topic evolve-ui
> templates: display evolution "troubles" in command line style

> +ltroubles = '{if(troubles, "{label('ui.note log.trouble',
> +                                   'trouble:     {join(troubles, ", ")}')}\n")}'

"ui.note" isn't necessary here (and in changeset_printer.) Some fields have
one just because they were previously written by ui.note() function (and now
that is covered by "if ui.verbose".)

Can you send a follow-up?

Patch

diff --git a/mercurial/templates/map-cmdline.default b/mercurial/templates/map-cmdline.default
--- a/mercurial/templates/map-cmdline.default
+++ b/mercurial/templates/map-cmdline.default
@@ -1,9 +1,9 @@ 
 # Base templates. Due to name clashes with existing keywords, we have
 # to replace some keywords with 'lkeyword', for 'labelled keyword'
-changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}\n'
+changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{summary}\n'
 changeset_quiet = '{lnode}'
-changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n'
-changeset_debug = '{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{lfile_mods}{lfile_adds}{lfile_dels}{lfile_copies_switch}{extras}{description}\n'
+changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{lfiles}{lfile_copies_switch}{description}\n'
+changeset_debug = '{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{ltroubles}{lfile_mods}{lfile_adds}{lfile_dels}{lfile_copies_switch}{extras}{description}\n'
 
 # File templates
 lfiles = '{if(files,
@@ -28,7 +28,8 @@  lfile_copies_switch = '{if(file_copies_s
                                                % ' {name} ({source})'}\n"))}'
 
 # General templates
-_cset_labels = 'log.changeset changeset.{phase}'
+_trouble_label = 'trouble.{trouble}'
+_cset_labels = 'log.changeset changeset.{phase}{if(troubles, " changeset.troubled {troubles%_trouble_label}")}'
 cset = '{label("{_cset_labels}",
                "changeset:   {rev}:{node|short}")}\n'
 
@@ -65,6 +66,9 @@  summary = '{if(desc|strip, "{label('log.
 ldate = '{label("log.date",
                 "date:        {date|date}")}\n'
 
+ltroubles = '{if(troubles, "{label('ui.note log.trouble',
+                                   'trouble:     {join(troubles, ", ")}')}\n")}'
+
 extra = '{label("ui.debug log.extra",
                 "extra:       {key}={value|stringescape}")}\n'
 
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -815,6 +815,16 @@  test the "troubles" templatekw
   $ hg log -r 'bumped() and unstable()'
   7:50c51b361e60 (draft unstable bumped) [ ] add babar
 
+test the default cmdline template
+
+  $ hg log -T default -r 'bumped()'
+  changeset:   7:50c51b361e60
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  trouble:     unstable, bumped
+  summary:     add babar
+  
+
 Test incoming/outcoming with changesets obsoleted remotely, known locally
 ===============================================================================