##// END OF EJS Templates
templater: do not abuse SyntaxError to report errors in template map file...
Yuya Nishihara -
r28628:ed1d90f6 default
parent child Browse files
Show More
@@ -19,7 +19,6 b' from mercurial import ('
19 cmdutil,
19 cmdutil,
20 commands,
20 commands,
21 encoding,
21 encoding,
22 error,
23 patch,
22 patch,
24 scmutil,
23 scmutil,
25 util,
24 util,
@@ -34,12 +33,7 b' command = cmdutil.command(cmdtable)'
34 testedwith = 'internal'
33 testedwith = 'internal'
35
34
36 def maketemplater(ui, repo, tmpl):
35 def maketemplater(ui, repo, tmpl):
37 try:
36 return cmdutil.changeset_templater(ui, repo, False, None, tmpl, None, False)
38 t = cmdutil.changeset_templater(ui, repo, False, None, tmpl,
39 None, False)
40 except SyntaxError as inst:
41 raise error.Abort(inst.args[0])
42 return t
43
37
44 def changedlines(ui, repo, ctx1, ctx2, fns):
38 def changedlines(ui, repo, ctx1, ctx2, fns):
45 added, removed = 0, 0
39 added, removed = 0, 0
@@ -1532,8 +1532,6 b' class changeset_templater(changeset_prin'
1532 except KeyError as inst:
1532 except KeyError as inst:
1533 msg = _("%s: no key named '%s'")
1533 msg = _("%s: no key named '%s'")
1534 raise error.Abort(msg % (self.t.mapfile, inst.args[0]))
1534 raise error.Abort(msg % (self.t.mapfile, inst.args[0]))
1535 except SyntaxError as inst:
1536 raise error.Abort('%s: %s' % (self.t.mapfile, inst.args[0]))
1537
1535
1538 def gettemplate(ui, tmpl, style):
1536 def gettemplate(ui, tmpl, style):
1539 """
1537 """
@@ -1590,12 +1588,7 b' def show_changeset(ui, repo, opts, buffe'
1590 if not tmpl and not mapfile:
1588 if not tmpl and not mapfile:
1591 return changeset_printer(ui, repo, matchfn, opts, buffered)
1589 return changeset_printer(ui, repo, matchfn, opts, buffered)
1592
1590
1593 try:
1591 return changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, buffered)
1594 t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile,
1595 buffered)
1596 except SyntaxError as inst:
1597 raise error.Abort(inst.args[0])
1598 return t
1599
1592
1600 def showmarker(ui, marker, index=None):
1593 def showmarker(ui, marker, index=None):
1601 """utility function to display obsolescence marker in a readable way
1594 """utility function to display obsolescence marker in a readable way
@@ -2843,10 +2836,7 b' def buildcommittemplate(repo, ctx, subs,'
2843 ui = repo.ui
2836 ui = repo.ui
2844 tmpl, mapfile = gettemplate(ui, tmpl, None)
2837 tmpl, mapfile = gettemplate(ui, tmpl, None)
2845
2838
2846 try:
2847 t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False)
2839 t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False)
2848 except SyntaxError as inst:
2849 raise error.Abort(inst.args[0])
2850
2840
2851 for k, v in repo.ui.configitems('committemplate'):
2841 for k, v in repo.ui.configitems('committemplate'):
2852 if k != 'changeset':
2842 if k != 'changeset':
@@ -978,13 +978,12 b' class templater(object):'
978
978
979 for key, val in conf[''].items():
979 for key, val in conf[''].items():
980 if not val:
980 if not val:
981 raise SyntaxError(_('%s: missing value') % conf.source('', key))
981 raise error.ParseError(_('missing value'), conf.source('', key))
982 if val[0] in "'\"":
982 if val[0] in "'\"":
983 try:
983 try:
984 self.cache[key] = unquotestring(val)
984 self.cache[key] = unquotestring(val)
985 except SyntaxError as inst:
985 except SyntaxError as inst:
986 raise SyntaxError('%s: %s' %
986 raise error.ParseError(inst.args[0], conf.source('', key))
987 (conf.source('', key), inst.args[0]))
988 else:
987 else:
989 val = 'default', val
988 val = 'default', val
990 if ':' in val[1]:
989 if ':' in val[1]:
@@ -1008,7 +1008,7 b' Error if style missing value:'
1008
1008
1009 $ echo 'changeset =' > t
1009 $ echo 'changeset =' > t
1010 $ hg log --style t
1010 $ hg log --style t
1011 abort: t:1: missing value
1011 hg: parse error at t:1: missing value
1012 [255]
1012 [255]
1013
1013
1014 Error if include fails:
1014 Error if include fails:
@@ -2508,7 +2508,7 b' Error on syntax:'
2508
2508
2509 $ echo 'x = "f' >> t
2509 $ echo 'x = "f' >> t
2510 $ hg log
2510 $ hg log
2511 abort: t:3: unmatched quotes
2511 hg: parse error at t:3: unmatched quotes
2512 [255]
2512 [255]
2513
2513
2514 $ hg log -T '{date'
2514 $ hg log -T '{date'
General Comments 0
You need to be logged in to leave comments. Login now