Bug 1178955 - Error when semicolon comments are seen; r=smacleod

configobj doesn't support semicolon comments. Why, I don't know, since
they are pretty common in ini files.

Do a static check for semicolon comments and print a more actionable
error message.

--HG--
extra : commitid : CULjsg4do9Z
extra : rebase_source : f135cc726462c73a8363ebb8c98092177cf7ffd3
extra : amend_source : 0b8c67d5b0be3bc07cf7ff4f136bb58d342368c4
This commit is contained in:
Gregory Szorc 2015-07-17 10:29:09 -07:00
parent 67d8bb157c
commit 402674db49
2 changed files with 8 additions and 4 deletions

View File

@ -30,7 +30,7 @@ def config_file(files):
return files[0]
class HgIncludeException(Exception):
class ParseException(Exception):
pass
@ -49,8 +49,12 @@ class MercurialConfig(object):
with codecs.open(path, 'r', encoding='utf-8') as f:
for line in f:
if line.startswith('%include'):
raise HgIncludeException(
raise ParseException(
'%include directive is not supported by MercurialConfig')
if line.startswith(';'):
raise ParseException(
'semicolon (;) comments are not supported; '
'use # instead')
# write_empty_values is necessary to prevent built-in extensions (which
# have no value) from being dropped on write.

View File

@ -22,8 +22,8 @@ from mozversioncontrol import get_hg_version
from .update import MercurialUpdater
from .config import (
config_file,
HgIncludeException,
MercurialConfig,
ParseException,
)
@ -227,7 +227,7 @@ class MercurialSetupWizard(object):
print(error.message)
return 1
except HgIncludeException as e:
except ParseException as e:
print('Error importing existing Mercurial config: %s\n' % config_path)
print(e.message)