Patchwork commands: hg debuginstall checks missing templates (issue4151)

login
register
mail settings
Submitter Simon Heimberg
Date Jan. 28, 2014, 2:31 a.m.
Message ID <9600f3e8da0b9062907e.1390876318@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/3416/
State Accepted
Commit 9a86b5b8e0d837f0c0bb7f2f1d442f0364089e65
Headers show

Comments

Simon Heimberg - Jan. 28, 2014, 2:31 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@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.
Matt Mackall - Feb. 7, 2014, 12:59 a.m.
On Tue, 2014-01-28 at 03:31 +0100, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1390817827 -3600
> # Branch stable
> # Node ID 9600f3e8da0b9062907e5db0504b9fff59157980
> # Parent  136fe91ade1d49e1845bb88064198af04e98d9e7
> commands: hg debuginstall checks missing templates (issue4151)

Queued for default, thanks.

Patch

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