Patchwork [2,of,2] templater: drop deprecated handling of KeyError from changeset_templater

login
register
mail settings
Submitter Yuya Nishihara
Date April 8, 2016, 3:57 p.m.
Message ID <0fb62a3160e5d12e2b84.1460131025@mimosa>
Download mbox | patch
Permalink /patch/14434/
State Accepted
Headers show

Comments

Yuya Nishihara - April 8, 2016, 3:57 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1459650211 -32400
#      Sun Apr 03 11:23:31 2016 +0900
# Node ID 0fb62a3160e5d12e2b8495c2fcf328fe1a9fdab0
# Parent  170ea5eb48ccdd68010c1a03d57702728f5d53cf
templater: drop deprecated handling of KeyError from changeset_templater

It's been superseded by 09cde75e0613 and the previous patch. templater.mapfile
is no longer used and removed.
Sean Farley - April 12, 2016, 8:05 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1459650211 -32400
> #      Sun Apr 03 11:23:31 2016 +0900
> # Node ID 0fb62a3160e5d12e2b8495c2fcf328fe1a9fdab0
> # Parent  170ea5eb48ccdd68010c1a03d57702728f5d53cf
> templater: drop deprecated handling of KeyError from changeset_templater
>
> It's been superseded by 09cde75e0613 and the previous patch. templater.mapfile
> is no longer used and removed.

These look good to me.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1532,29 +1532,25 @@  class changeset_templater(changeset_prin
         props['revcache'] = {'copies': copies}
         props['cache'] = self.cache
 
-        try:
-            # write header
-            if self._parts['header']:
-                h = templater.stringify(self.t(self._parts['header'], **props))
-                if self.buffered:
-                    self.header[ctx.rev()] = h
-                else:
-                    if self.lastheader != h:
-                        self.lastheader = h
-                        self.ui.write(h)
-
-            # write changeset metadata, then patch if requested
-            key = self._parts['changeset']
-            self.ui.write(templater.stringify(self.t(key, **props)))
-            self.showpatch(ctx, matchfn)
-
-            if self._parts['footer']:
-                if not self.footer:
-                    self.footer = templater.stringify(
-                        self.t(self._parts['footer'], **props))
-        except KeyError as inst:
-            msg = _("%s: no key named '%s'")
-            raise error.Abort(msg % (self.t.mapfile, inst.args[0]))
+        # write header
+        if self._parts['header']:
+            h = templater.stringify(self.t(self._parts['header'], **props))
+            if self.buffered:
+                self.header[ctx.rev()] = h
+            else:
+                if self.lastheader != h:
+                    self.lastheader = h
+                    self.ui.write(h)
+
+        # write changeset metadata, then patch if requested
+        key = self._parts['changeset']
+        self.ui.write(templater.stringify(self.t(key, **props)))
+        self.showpatch(ctx, matchfn)
+
+        if self._parts['footer']:
+            if not self.footer:
+                self.footer = templater.stringify(
+                    self.t(self._parts['footer'], **props))
 
 def gettemplate(ui, tmpl, style):
     """
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -956,7 +956,6 @@  class templater(object):
             defaults = {}
         if cache is None:
             cache = {}
-        self.mapfile = mapfile or 'template'
         self.cache = cache.copy()
         self.map = {}
         if mapfile: