Mercurial > hg-stable
changeset 8194:63c47e4ac617
templater: use new config parser
This gives us the ability to use includes and continuations
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:43 -0500 |
parents | 94246e90081e |
children | 1750510251d0 |
files | mercurial/templater.py |
diffstat | 1 files changed, 12 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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