Mercurial > public > mercurial-scm > hg
diff mercurial/cmdutil.py @ 28628:ed1d90f6e921
templater: do not abuse SyntaxError to report errors in template map file
SyntaxError is the class representing syntax errors in Python code. We should
use a dedicated exception class for our needs. With this change, unnecessary
re-wrapping of SyntaxError can be eliminated.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 Mar 2016 18:01:04 +0900 |
parents | 1a1e4350b560 |
children | bf35644b9f3a |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Mar 23 13:34:47 2016 -0700 +++ b/mercurial/cmdutil.py Sat Mar 26 18:01:04 2016 +0900 @@ -1532,8 +1532,6 @@ except KeyError as inst: msg = _("%s: no key named '%s'") raise error.Abort(msg % (self.t.mapfile, inst.args[0])) - except SyntaxError as inst: - raise error.Abort('%s: %s' % (self.t.mapfile, inst.args[0])) def gettemplate(ui, tmpl, style): """ @@ -1590,12 +1588,7 @@ if not tmpl and not mapfile: return changeset_printer(ui, repo, matchfn, opts, buffered) - try: - t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, - buffered) - except SyntaxError as inst: - raise error.Abort(inst.args[0]) - return t + return changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, buffered) def showmarker(ui, marker, index=None): """utility function to display obsolescence marker in a readable way @@ -2843,10 +2836,7 @@ ui = repo.ui tmpl, mapfile = gettemplate(ui, tmpl, None) - try: - t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False) - except SyntaxError as inst: - raise error.Abort(inst.args[0]) + t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False) for k, v in repo.ui.configitems('committemplate'): if k != 'changeset':