# HG changeset patch # User Yuya Nishihara # Date 2018-04-26 12:24:13 # Node ID 0e9ddab2bac2de45c1cb848fa00faf3c2bda20d2 # Parent da07c781aba9ef88cbf76d07c6a6e2ec40cf6693 debugcolor: fix crash by empty styles (issue5856) diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -462,6 +462,8 @@ def _debugdisplaycolor(ui): 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) diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t --- a/tests/test-debugcommands.t +++ b/tests/test-debugcommands.t @@ -333,6 +333,19 @@ Test cache warming command .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