comparison hgext/churn.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 70d3dc05e118
children d5883fd055c6
comparison
equal deleted inserted replaced
28627:d7af9b4ae7dd 28628:ed1d90f6e921
17 from mercurial.i18n import _ 17 from mercurial.i18n import _
18 from mercurial import ( 18 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,
26 ) 25 )
27 26
32 # be specifying the version(s) of Mercurial they are tested with, or 31 # be specifying the version(s) of Mercurial they are tested with, or
33 # leave the attribute unspecified. 32 # leave the attribute unspecified.
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
46 fmatch = scmutil.matchfiles(repo, fns) 40 fmatch = scmutil.matchfiles(repo, fns)
47 diff = ''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch)) 41 diff = ''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))