Bug 1184229 - Detect multiple version-control-tools repos in Mercurial config; r=smacleod

Having multiple version-control-tools repositories references in your
hgrc could lead to one repository importing code from another, depending
on how sys.path modification works from version-control-tools
repositories. Detect it and issue a warning.
This commit is contained in:
Gregory Szorc 2015-07-27 13:44:39 -07:00
parent 1f08fd1eaf
commit 1805842782

View File

@ -213,6 +213,20 @@ Sensitive information such as your Bugzilla credentials could be
stolen if others have access to this file/machine.
'''.strip()
MULTIPLE_VCT = '''
*** WARNING ***
Multiple version-control-tools repositories are referenced in your
Mercurial config. Extensions and other code within the
version-control-tools repository could run with inconsistent results.
Please manually edit the following file to reference a single
version-control-tools repository:
%s
'''.lstrip()
class MercurialSetupWizard(object):
"""Command-line wizard to help users configure Mercurial."""
@ -404,6 +418,23 @@ class MercurialSetupWizard(object):
c.add_mozilla_host_fingerprints()
# References to multiple version-control-tools checkouts can confuse
# version-control-tools, since various Mercurial extensions resolve
# dependencies via __file__ and repos could reference another copy.
seen_vct = set()
for k, v in c.config.get('extensions', {}).items():
if 'version-control-tools' not in v:
continue
i = v.index('version-control-tools')
vct = v[0:i + len('version-control-tools')]
seen_vct.add(os.path.realpath(os.path.expanduser(vct)))
if len(seen_vct) > 1:
print(MULTIPLE_VCT % c.config_path)
# At this point the config should be finalized.
b = StringIO()
c.write(b)
new_lines = [line.rstrip() for line in b.getvalue().splitlines()]