Bug 1047592 - mercurial-setup should error when trying to read a config with %include. r=gps

This commit is contained in:
Patrick Cloke 2014-08-05 09:42:33 -04:00
parent b4e226068a
commit ecc2933e4b
2 changed files with 18 additions and 0 deletions

View File

@ -16,6 +16,10 @@ HOST_FINGERPRINTS = {
}
class HgIncludeException(Exception):
pass
class MercurialConfig(object):
"""Interface for manipulating a Mercurial config file."""
@ -35,6 +39,15 @@ class MercurialConfig(object):
else:
infile = None
# Mercurial configuration files allow an %include directive to include
# other files, this is not supported by ConfigObj, so throw a useful
# error saying this.
with open(infile, 'r') as f:
for line in f:
if line.startswith('%include'):
raise HgIncludeException(
'%include directive is not supported by MercurialConfig')
# write_empty_values is necessary to prevent built-in extensions (which
# have no value) from being dropped on write.
# list_values aren't needed by Mercurial and disabling them prevents

View File

@ -23,6 +23,7 @@ from mozversioncontrol.repoupdate import (
)
from .config import (
HgIncludeException,
HOST_FINGERPRINTS,
MercurialConfig,
)
@ -195,6 +196,10 @@ class MercurialSetupWizard(object):
print(error.message)
return 1
except HgIncludeException as e:
print(e.message)
return 1
print(INITIAL_MESSAGE)
raw_input()