##// END OF EJS Templates
templater: simplify merge of __base__ dicts by reading it first
Yuya Nishihara -
r34713:56f08533 default
parent child Browse files
Show More
@@ -1344,6 +1344,26 b' def _readmapfile(mapfile):'
1344
1344
1345 cache = {}
1345 cache = {}
1346 tmap = {}
1346 tmap = {}
1347
1348 val = conf.get('', '__base__')
1349 if val and val[0] not in "'\"":
1350 # treat as a pointer to a base class for this style
1351 path = util.normpath(os.path.join(base, val))
1352
1353 # fallback check in template paths
1354 if not os.path.exists(path):
1355 for p in templatepaths():
1356 p2 = util.normpath(os.path.join(p, val))
1357 if os.path.isfile(p2):
1358 path = p2
1359 break
1360 p3 = util.normpath(os.path.join(p2, "map"))
1361 if os.path.isfile(p3):
1362 path = p3
1363 break
1364
1365 cache, tmap = _readmapfile(path)
1366
1347 for key, val in conf[''].items():
1367 for key, val in conf[''].items():
1348 if not val:
1368 if not val:
1349 raise error.ParseError(_('missing value'), conf.source('', key))
1369 raise error.ParseError(_('missing value'), conf.source('', key))
@@ -1352,30 +1372,7 b' def _readmapfile(mapfile):'
1352 raise error.ParseError(_('unmatched quotes'),
1372 raise error.ParseError(_('unmatched quotes'),
1353 conf.source('', key))
1373 conf.source('', key))
1354 cache[key] = unquotestring(val)
1374 cache[key] = unquotestring(val)
1355 elif key == "__base__":
1375 elif key != '__base__':
1356 # treat as a pointer to a base class for this style
1357 path = util.normpath(os.path.join(base, val))
1358
1359 # fallback check in template paths
1360 if not os.path.exists(path):
1361 for p in templatepaths():
1362 p2 = util.normpath(os.path.join(p, val))
1363 if os.path.isfile(p2):
1364 path = p2
1365 break
1366 p3 = util.normpath(os.path.join(p2, "map"))
1367 if os.path.isfile(p3):
1368 path = p3
1369 break
1370
1371 bcache, btmap = _readmapfile(path)
1372 for k in bcache:
1373 if k not in cache:
1374 cache[k] = bcache[k]
1375 for k in btmap:
1376 if k not in tmap:
1377 tmap[k] = btmap[k]
1378 else:
1379 val = 'default', val
1376 val = 'default', val
1380 if ':' in val[1]:
1377 if ':' in val[1]:
1381 val = val[1].split(':', 1)
1378 val = val[1].split(':', 1)
General Comments 0
You need to be logged in to leave comments. Login now