templater: handle a missing value correctly stable
authorRoss Lagerwall <rosslagerwall@gmail.com>
Sat, 04 Aug 2012 14:37:17 +0200
branchstable
changeset 17334 39c01f8e7b39
parent 17333 ba36e771f268
child 17335 b5c560787a4e
templater: handle a missing value correctly Before, using a broken style such as: changeset = would result in a traceback. This fixes a regression introduced in 63c47e4ac617.
mercurial/templater.py
tests/test-command-template.t
--- a/mercurial/templater.py	Sat Aug 04 12:29:53 2012 +0200
+++ b/mercurial/templater.py	Sat Aug 04 14:37:17 2012 +0200
@@ -295,6 +295,8 @@
         conf.read(mapfile)
 
         for key, val in conf[''].items():
+            if not val:
+                raise SyntaxError(_('%s: missing value') % conf.source('', key))
             if val[0] in "'\"":
                 try:
                     self.cache[key] = parsestring(val)
--- a/tests/test-command-template.t	Sat Aug 04 12:29:53 2012 +0200
+++ b/tests/test-command-template.t	Sat Aug 04 14:37:17 2012 +0200
@@ -463,6 +463,13 @@
   abort: "changeset" not in template map
   [255]
 
+Error if style missing value:
+
+  $ echo 'changeset =' > t
+  $ hg log --style t
+  abort: t:1: missing value
+  [255]
+
 Error if include fails:
 
   $ echo 'changeset = q' >> t