##// END OF EJS Templates
templater: support using templates with non-standard names from map file...
Alexander Plavin -
r19770:0361163e default
parent child Browse files
Show More
@@ -139,7 +139,12 def runstring(context, mapping, data):
139 139 def runsymbol(context, mapping, key):
140 140 v = mapping.get(key)
141 141 if v is None:
142 v = context._defaults.get(key, '')
142 v = context._defaults.get(key)
143 if v is None:
144 try:
145 v = context.process(key, mapping)
146 except TemplateNotFound:
147 v = ''
143 148 if util.safehasattr(v, '__call__'):
144 149 return v(**mapping)
145 150 if isinstance(v, types.GeneratorType):
@@ -449,6 +454,9 def stylelist():
449 454 stylelist.append(split[1])
450 455 return ", ".join(sorted(stylelist))
451 456
457 class TemplateNotFound(util.Abort):
458 pass
459
452 460 class templater(object):
453 461
454 462 def __init__(self, mapfile, filters={}, defaults={}, cache={},
@@ -500,7 +508,8 class templater(object):
500 508 try:
501 509 self.cache[t] = util.readfile(self.map[t][1])
502 510 except KeyError, inst:
503 raise util.Abort(_('"%s" not in template map') % inst.args[0])
511 raise TemplateNotFound(_('"%s" not in template map') %
512 inst.args[0])
504 513 except IOError, inst:
505 514 raise IOError(inst.args[0], _('template file %s: %s') %
506 515 (self.map[t][1], inst.args[1]))
@@ -500,6 +500,28 Include works:
500 500 1
501 501 0
502 502
503 Missing non-standard names give no error (backward compatibility):
504
505 $ echo "changeset = '{c}'" > t
506 $ hg log --style ./t
507
508 Defining non-standard name works:
509
510 $ cat <<EOF > t
511 > changeset = '{c}'
512 > c = q
513 > EOF
514 $ hg log --style ./t
515 8
516 7
517 6
518 5
519 4
520 3
521 2
522 1
523 0
524
503 525 ui.style works:
504 526
505 527 $ echo '[ui]' > .hg/hgrc
General Comments 0
You need to be logged in to leave comments. Login now