changeset 37823:0e9ddab2bac2 stable

debugcolor: fix crash by empty styles (issue5856)
author Yuya Nishihara <yuya@tcha.org>
date Thu, 26 Apr 2018 21:24:13 +0900
parents da07c781aba9
children 2968ad548583
files mercurial/debugcommands.py tests/test-debugcommands.t
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Apr 25 14:51:20 2018 -0700
+++ b/mercurial/debugcommands.py	Thu Apr 26 21:24:13 2018 +0900
@@ -462,6 +462,8 @@
 
 def _debugdisplaystyle(ui):
     ui.write(_('available style:\n'))
+    if not ui._styles:
+        return
     width = max(len(s) for s in ui._styles)
     for label, effects in sorted(ui._styles.items()):
         ui.write('%s' % label, label=label)
--- a/tests/test-debugcommands.t	Wed Apr 25 14:51:20 2018 -0700
+++ b/tests/test-debugcommands.t	Thu Apr 26 21:24:13 2018 +0900
@@ -333,6 +333,19 @@
   .hg/cache/rbc-names-v1
   .hg/cache/branch2-served
 
+Test debugcolor
+
+#if no-windows
+  $ hg debugcolor --style --color always | egrep 'mode|style|log\.'
+  color mode: ansi
+  available style:
+  \x1b[0;33mlog.changeset\x1b[0m:                      \x1b[0;33myellow\x1b[0m (esc)
+#endif
+
+  $ hg debugcolor --style --color never
+  color mode: None
+  available style:
+
   $ cd ..
 
 Test internal debugstacktrace command