[PATCH] commands: hg debuginstall checks missing templates (issue4151)

Simon Heimberg simohe at besonet.ch
Mon Jan 27 20:31:58 CST 2014


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1390817827 -3600
# Branch stable
# Node ID 9600f3e8da0b9062907e5db0504b9fff59157980
# Parent  136fe91ade1d49e1845bb88064198af04e98d9e7
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 136fe91ade1d -r 9600f3e8da0b mercurial/commands.py
--- a/mercurial/commands.py	Fre Jan 17 19:22:31 2014 +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
 


More information about the Mercurial-devel mailing list