##// 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 b' def runstring(context, mapping, data):'
139 def runsymbol(context, mapping, key):
139 def runsymbol(context, mapping, key):
140 v = mapping.get(key)
140 v = mapping.get(key)
141 if v is None:
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 if util.safehasattr(v, '__call__'):
148 if util.safehasattr(v, '__call__'):
144 return v(**mapping)
149 return v(**mapping)
145 if isinstance(v, types.GeneratorType):
150 if isinstance(v, types.GeneratorType):
@@ -449,6 +454,9 b' def stylelist():'
449 stylelist.append(split[1])
454 stylelist.append(split[1])
450 return ", ".join(sorted(stylelist))
455 return ", ".join(sorted(stylelist))
451
456
457 class TemplateNotFound(util.Abort):
458 pass
459
452 class templater(object):
460 class templater(object):
453
461
454 def __init__(self, mapfile, filters={}, defaults={}, cache={},
462 def __init__(self, mapfile, filters={}, defaults={}, cache={},
@@ -500,7 +508,8 b' class templater(object):'
500 try:
508 try:
501 self.cache[t] = util.readfile(self.map[t][1])
509 self.cache[t] = util.readfile(self.map[t][1])
502 except KeyError, inst:
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 except IOError, inst:
513 except IOError, inst:
505 raise IOError(inst.args[0], _('template file %s: %s') %
514 raise IOError(inst.args[0], _('template file %s: %s') %
506 (self.map[t][1], inst.args[1]))
515 (self.map[t][1], inst.args[1]))
@@ -500,6 +500,28 b' Include works:'
500 1
500 1
501 0
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 ui.style works:
525 ui.style works:
504
526
505 $ echo '[ui]' > .hg/hgrc
527 $ echo '[ui]' > .hg/hgrc
General Comments 0
You need to be logged in to leave comments. Login now