# HG changeset patch # User Matt Mackall # Date 1240782643 18000 # Node ID 63c47e4ac6170f201d5a2d57f25b9ac0afeba0ab # Parent 94246e90081ea8a9d20f76e9a0d91cbd38b00232 templater: use new config parser This gives us the ability to use includes and continuations diff -r 94246e90081e -r 63c47e4ac617 mercurial/templater.py --- a/mercurial/templater.py Sun Apr 26 16:50:43 2009 -0500 +++ b/mercurial/templater.py Sun Apr 26 16:50:43 2009 -0500 @@ -7,7 +7,7 @@ from i18n import _ import re, sys, os -from mercurial import util +from mercurial import util, config path = ['templates', '../templates'] @@ -63,24 +63,18 @@ if not os.path.exists(mapfile): raise util.Abort(_('style not found: %s') % mapfile) - i = 0 - for l in file(mapfile): - l = l.strip() - i += 1 - if not l or l[0] in '#;': continue - m = re.match(r'([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+)$', l) - if m: - key, val = m.groups() - if val[0] in "'\"": - try: - self.cache[key] = parsestring(val) - except SyntaxError, inst: - raise SyntaxError('%s:%s: %s' % - (mapfile, i, inst.args[0])) - else: - self.map[key] = os.path.join(self.base, val) + conf = config.config() + conf.read(mapfile) + + for key, val in conf[''].items(): + if val[0] in "'\"": + try: + self.cache[key] = parsestring(val) + except SyntaxError, inst: + raise SyntaxError('%s: %s' % + (conf.getsource('', key), inst.args[0])) else: - raise SyntaxError(_("%s:%s: parse error") % (mapfile, i)) + self.map[key] = os.path.join(self.base, val) def __contains__(self, key): return key in self.cache or key in self.map