# HG changeset patch # User Simon Heimberg # Date 2014-01-23 00:29:50 # Node ID 268a5ab5c27bee4312c5f060cefab4de6cbdadba # Parent 8824009d270430e4cb5b56c8d3e49e6a34518415 templater: selecting a style with no templates does not crash (issue4140) Running `hg log --style compact` (or any other style) raised a traceback when no template directory was there. Now there is a message: Abort: style 'compact' not found (available styles: no templates found, try `hg debuginstall` for more info) There is no test because this would require to rename the template directory. But this would influence other tests running in parallel. And when the test would be aborted the wrong named directory would remain, especially a problem when running with -l. diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -447,8 +447,10 @@ class engine(object): engines = {'default': engine} def stylelist(): - path = templatepath()[0] - dirlist = os.listdir(path) + paths = templatepath() + if not paths: + return _('no templates found, try `hg debuginstall` for more info') + dirlist = os.listdir(paths[0]) stylelist = [] for file in dirlist: split = file.split(".")