changeset 20389:9a86b5b8e0d8

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.
author Simon Heimberg <simohe@besonet.ch>
date Mon, 27 Jan 2014 11:17:07 +0100
parents 9fe578297b5c
children 3fedc29a98bb
files mercurial/commands.py
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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