# HG changeset patch # User Simon Heimberg # Date 1390817827 -3600 # Node ID 9a86b5b8e0d837f0c0bb7f2f1d442f0364089e65 # Parent 9fe578297b5c3f63512cc003c6fcdca85fa66435 commands: hg debuginstall checks missing templates (issue4151) Missing templates where not reported as a problem, only an empty bracket were shown as indication of no found template directory: $ hg debuginstall *...some lines* checking templates ()... *...some lines* no problems detected Now the problem is reported and extended with some information. The style of the messages is adapted to the other messages of debuginstall. When no templates directories exist, it writes: $ hg debuginstall *...some lines* checking templates ()... no template directories found (templates seem to have been installed incorrectly) *...some lines* 1 problems detected, please check your install! When the template map is not found, it writes: $ hg debuginstall *...some lines* checking templates (/path/to/mercurial/templates)... template 'default' not found (templates seem to have been installed incorrectly) *...some lines* 1 problems detected, please check your install! When the template map is buggy the message is the same as before. The error message is shown before the line "(templates seem ...)". No test is added because testing this failure is complicated. It would require to modify the templates directory of the mercurial installation, or to monkey patch a function (os.listdir or any from mercurial.templater) by a test extension. diff -r 9fe578297b5c -r 9a86b5b8e0d8 mercurial/commands.py --- a/mercurial/commands.py Sun Feb 10 00:11:45 2013 +0100 +++ b/mercurial/commands.py Mon Jan 27 11:17:07 2014 +0100 @@ -2107,10 +2107,21 @@ import templater p = templater.templatepath() ui.status(_("checking templates (%s)...\n") % ' '.join(p)) - try: - templater.templater(templater.templatepath("map-cmdline.default")) - except Exception, inst: - ui.write(" %s\n" % inst) + if p: + m = templater.templatepath("map-cmdline.default") + if m: + # template found, check if it is working + try: + templater.templater(m) + except Exception, inst: + ui.write(" %s\n" % inst) + p = None + else: + ui.write(_(" template 'default' not found\n")) + p = None + else: + ui.write(_(" no template directories found\n")) + if not p: ui.write(_(" (templates seem to have been installed incorrectly)\n")) problems += 1