Chromium Code Reviews| Index: gclient.py |
| diff --git a/gclient.py b/gclient.py |
| index 86b742f594ed7252674207cd286ecd5f06fca115..913112e7918270e62be04437075361ad21404ece 100755 |
| --- a/gclient.py |
| +++ b/gclient.py |
| @@ -78,6 +78,7 @@ |
| __version__ = '0.7' |
| +import atexit |
|
borenet
2014/03/14 13:30:57
Is atexit acceptable for this? It would be nice to
iannucci
2014/03/17 17:38:40
Hm. I would probably wrap atexit instead of direct
borenet
2014/03/17 17:41:33
Alternatively, I can just call the _CheckConfig me
|
| import copy |
| import json |
| import logging |
| @@ -1044,6 +1045,42 @@ solutions = [ |
| self._root_dir = root_dir |
| self.config_content = None |
| + def _CheckConfig(self): |
| + """Verify that the config matches any existing checkout.""" |
| + for dep in self.dependencies: |
| + if dep.managed: |
| + scm = gclient_scm.CreateSCM(dep.url, self.root_dir, dep.name) |
| + actual_url = scm.GetActualRemoteURL() |
| + if actual_url and not scm.DoesRemoteURLMatch(): |
| + def print_warning(): |
| + print >> sys.stderr, (''' |
| +################################################################################ |
| +################################### WARNING! ################################### |
| +################################################################################ |
| + |
| +Your .gclient file seems to be broken. The requested URL is different from what |
| +is actually checked out in %(checkout_path)s. In the future this will be an |
| +error. |
| + |
| +Expected: %(expected_url)s (%(expected_scm)s) |
| +Actual: %(actual_url)s (%(actual_scm)s) |
| + |
| +You should ensure that the URL listed in .gclient is correct and either change |
| +it or fix the checkout. If you're managing your own git checkout in |
| +%(checkout_path)s but the URL in .gclient is for an svn repository, you probably |
| +want to set 'managed': False in .gclient. |
| + |
| +################################################################################ |
| +################################################################################ |
| +################################################################################ |
| +''' % {'checkout_path': os.path.join(self.root_dir, dep.name), |
| + 'expected_url': dep.url, |
| + 'expected_scm': gclient_scm.GetScmName(dep.url), |
| + 'actual_url': actual_url, |
| + 'actual_scm': gclient_scm.GetScmName(actual_url)}) |
| + |
| + atexit.register(print_warning) |
| + |
| def SetConfig(self, content): |
| assert not self.dependencies |
| config_dict = {} |
| @@ -1082,6 +1119,7 @@ solutions = [ |
| raise gclient_utils.Error('Invalid .gclient file. Solution is ' |
| 'incomplete: %s' % s) |
| self.add_dependencies_and_close(deps_to_add, config_dict.get('hooks', [])) |
| + self._CheckConfig() |
| logging.info('SetConfig() done') |
| def SaveConfig(self): |
| @@ -1694,6 +1732,7 @@ def CMDsync(parser, args): |
| # Print out the .gclient file. This is longer than if we just printed the |
| # client dict, but more legible, and it might contain helpful comments. |
| print(client.config_content) |
| + |
| ret = client.RunOnDeps('update', args) |
| if options.output_json: |
| slns = {} |