Bug 1178955 - Print line number for parse errors; r=smacleod

It helps users debug problems.

--HG--
extra : commitid : IU6Cw35FEiM
extra : rebase_source : f6ab1ef356bb10b689f2fed034a9f2564ffe0fc3
extra : amend_source : ef52d60ca12796fcfe32392077a7606628a54d29
This commit is contained in:
Gregory Szorc 2015-07-17 10:29:22 -07:00
Родитель 402674db49
Коммит a6bb6ec5af
2 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -31,7 +31,9 @@ def config_file(files):
class ParseException(Exception):
pass
def __init__(self, line, msg):
self.line = line
super(Exception, self).__init__(msg)
class MercurialConfig(object):
@ -47,12 +49,12 @@ class MercurialConfig(object):
# error saying this.
if os.path.exists(path):
with codecs.open(path, 'r', encoding='utf-8') as f:
for line in f:
for i, line in enumerate(f):
if line.startswith('%include'):
raise ParseException(
raise ParseException(i + 1,
'%include directive is not supported by MercurialConfig')
if line.startswith(';'):
raise ParseException(
raise ParseException(i + 1,
'semicolon (;) comments are not supported; '
'use # instead')

Просмотреть файл

@ -229,7 +229,7 @@ class MercurialSetupWizard(object):
return 1
except ParseException as e:
print('Error importing existing Mercurial config: %s\n' % config_path)
print(e.message)
print('Line %d: %s' % (e.line, e.message))
return 1