templater: give slightly nicer error for unknown map entries
authorMatt Mackall <mpm@selenic.com>
Mon, 20 Dec 2010 12:09:00 -0600
changeset 13175 09cde75e0613
parent 13174 be7e8e9bc5e5
child 13176 895f54a79c6e
templater: give slightly nicer error for unknown map entries
mercurial/templater.py
tests/test-command-template.t
--- a/mercurial/templater.py	Tue Dec 07 22:14:43 2010 -0600
+++ b/mercurial/templater.py	Mon Dec 20 12:09:00 2010 -0600
@@ -214,6 +214,8 @@
         if not t in self.cache:
             try:
                 self.cache[t] = open(self.map[t][1]).read()
+            except KeyError, inst:
+                raise util.Abort(_('"%s" not in template map') % inst.args[0])
             except IOError, inst:
                 raise IOError(inst.args[0], _('template file %s: %s') %
                               (self.map[t][1], inst.args[1]))
--- a/tests/test-command-template.t	Tue Dec 07 22:14:43 2010 -0600
+++ b/tests/test-command-template.t	Mon Dec 20 12:09:00 2010 -0600
@@ -449,7 +449,7 @@
 
   $ echo 'q = q' > t
   $ hg log --style ./t
-  abort: ./t: no key named 'changeset'
+  abort: "changeset" not in template map
   [255]
 
 Error if include fails: