diff mercurial/templater.py @ 20312:268a5ab5c27b stable

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.
author Simon Heimberg <simohe@besonet.ch>
date Thu, 23 Jan 2014 01:29:50 +0100
parents 3d8bfe2ecf6d
children 9c6b86dd2ed2 7e627fe63e5e
line wrap: on
line diff
--- a/mercurial/templater.py	Thu Jan 23 14:31:05 2014 -0600
+++ b/mercurial/templater.py	Thu Jan 23 01:29:50 2014 +0100
@@ -447,8 +447,10 @@
 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(".")