changeset 34712:56f085334611

templater: simplify merge of __base__ dicts by reading it first
author Yuya Nishihara <yuya@tcha.org>
date Sat, 20 Aug 2016 18:33:02 +0900
parents f6d17075608f
children e5a2cfc524d4
files mercurial/templater.py
diffstat 1 files changed, 21 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Sun Oct 08 17:23:18 2017 +0200
+++ b/mercurial/templater.py	Sat Aug 20 18:33:02 2016 +0900
@@ -1344,6 +1344,26 @@
 
     cache = {}
     tmap = {}
+
+    val = conf.get('', '__base__')
+    if val and val[0] not in "'\"":
+        # treat as a pointer to a base class for this style
+        path = util.normpath(os.path.join(base, val))
+
+        # fallback check in template paths
+        if not os.path.exists(path):
+            for p in templatepaths():
+                p2 = util.normpath(os.path.join(p, val))
+                if os.path.isfile(p2):
+                    path = p2
+                    break
+                p3 = util.normpath(os.path.join(p2, "map"))
+                if os.path.isfile(p3):
+                    path = p3
+                    break
+
+        cache, tmap = _readmapfile(path)
+
     for key, val in conf[''].items():
         if not val:
             raise error.ParseError(_('missing value'), conf.source('', key))
@@ -1352,30 +1372,7 @@
                 raise error.ParseError(_('unmatched quotes'),
                                        conf.source('', key))
             cache[key] = unquotestring(val)
-        elif key == "__base__":
-            # treat as a pointer to a base class for this style
-            path = util.normpath(os.path.join(base, val))
-
-            # fallback check in template paths
-            if not os.path.exists(path):
-                for p in templatepaths():
-                    p2 = util.normpath(os.path.join(p, val))
-                    if os.path.isfile(p2):
-                        path = p2
-                        break
-                    p3 = util.normpath(os.path.join(p2, "map"))
-                    if os.path.isfile(p3):
-                        path = p3
-                        break
-
-            bcache, btmap = _readmapfile(path)
-            for k in bcache:
-                if k not in cache:
-                    cache[k] = bcache[k]
-            for k in btmap:
-                if k not in tmap:
-                    tmap[k] = btmap[k]
-        else:
+        elif key != '__base__':
             val = 'default', val
             if ':' in val[1]:
                 val = val[1].split(':', 1)