Patchwork [3,of,9] templater: demote "base" directory of map file to local variable

login
register
mail settings
Submitter Yuya Nishihara
Date April 15, 2016, 1:15 p.m.
Message ID <00ae86afdecc3366a3dd.1460726142@mimosa>
Download mbox | patch
Permalink /patch/14642/
State Accepted
Headers show

Comments

Yuya Nishihara - April 15, 2016, 1:15 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1459693363 -32400
#      Sun Apr 03 23:22:43 2016 +0900
# Node ID 00ae86afdecc3366a3dd5a5dfcd31255c7016873
# Parent  a6bfba7f79df88616e005b693157221528c41c0d
templater: demote "base" directory of map file to local variable

It isn't referenced from other places.

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1003,10 +1003,6 @@  class templater(object):
             cache = {}
         self.cache = cache.copy()
         self.map = {}
-        if mapfile:
-            self.base = os.path.dirname(mapfile)
-        else:
-            self.base = ''
         self.filters = templatefilters.filters.copy()
         self.filters.update(filters)
         self.defaults = defaults
@@ -1019,6 +1015,7 @@  class templater(object):
             raise error.Abort(_("style '%s' not found") % mapfile,
                              hint=_("available styles: %s") % stylelist())
 
+        base = os.path.dirname(mapfile)
         conf = config.config(includepaths=templatepaths())
         conf.read(mapfile)
 
@@ -1034,7 +1031,7 @@  class templater(object):
                 val = 'default', val
                 if ':' in val[1]:
                     val = val[1].split(':', 1)
-                self.map[key] = val[0], os.path.join(self.base, val[1])
+                self.map[key] = val[0], os.path.join(base, val[1])
 
     def __contains__(self, key):
         return key in self.cache or key in self.map