OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Meta checkout manager supporting both Subversion and GIT.""" | 6 """Meta checkout manager supporting both Subversion and GIT.""" |
7 # Files | 7 # Files |
8 # .gclient : Current client configuration, written by 'config' command. | 8 # .gclient : Current client configuration, written by 'config' command. |
9 # Format is a Python script defining 'solutions', a list whose | 9 # Format is a Python script defining 'solutions', a list whose |
10 # entries each are maps binding the strings "name" and "url" | 10 # entries each are maps binding the strings "name" and "url" |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 if options.deps_os: | 1037 if options.deps_os: |
1038 enforced_os = options.deps_os.split(',') | 1038 enforced_os = options.deps_os.split(',') |
1039 else: | 1039 else: |
1040 enforced_os = [self.DEPS_OS_CHOICES.get(sys.platform, 'unix')] | 1040 enforced_os = [self.DEPS_OS_CHOICES.get(sys.platform, 'unix')] |
1041 if 'all' in enforced_os: | 1041 if 'all' in enforced_os: |
1042 enforced_os = self.DEPS_OS_CHOICES.itervalues() | 1042 enforced_os = self.DEPS_OS_CHOICES.itervalues() |
1043 self._enforced_os = tuple(set(enforced_os)) | 1043 self._enforced_os = tuple(set(enforced_os)) |
1044 self._root_dir = root_dir | 1044 self._root_dir = root_dir |
1045 self.config_content = None | 1045 self.config_content = None |
1046 | 1046 |
| 1047 def _CheckConfig(self): |
| 1048 """Verify that the config matches the state of the existing checked-out |
| 1049 solutions.""" |
| 1050 for dep in self.dependencies: |
| 1051 if dep.managed and dep.url: |
| 1052 scm = gclient_scm.CreateSCM(dep.url, self.root_dir, dep.name) |
| 1053 actual_url = scm.GetActualRemoteURL() |
| 1054 if actual_url and not scm.DoesRemoteURLMatch(): |
| 1055 print >> sys.stderr, (''' |
| 1056 ################################################################################ |
| 1057 ################################### WARNING! ################################### |
| 1058 ################################################################################ |
| 1059 |
| 1060 Your .gclient file seems to be broken. The requested URL is different from what |
| 1061 is actually checked out in %(checkout_path)s. In the future this will be an |
| 1062 error. |
| 1063 |
| 1064 Expected: %(expected_url)s (%(expected_scm)s) |
| 1065 Actual: %(actual_url)s (%(actual_scm)s) |
| 1066 |
| 1067 You should ensure that the URL listed in .gclient is correct and either change |
| 1068 it or fix the checkout. If you're managing your own git checkout in |
| 1069 %(checkout_path)s but the URL in .gclient is for an svn repository, you probably |
| 1070 want to set 'managed': False in .gclient. |
| 1071 |
| 1072 ################################################################################ |
| 1073 ################################################################################ |
| 1074 ################################################################################ |
| 1075 ''' % {'checkout_path': os.path.join(self.root_dir, dep.name), |
| 1076 'expected_url': dep.url, |
| 1077 'expected_scm': gclient_scm.GetScmName(dep.url), |
| 1078 'actual_url': actual_url, |
| 1079 'actual_scm': gclient_scm.GetScmName(actual_url)}) |
| 1080 |
1047 def SetConfig(self, content): | 1081 def SetConfig(self, content): |
1048 assert not self.dependencies | 1082 assert not self.dependencies |
1049 config_dict = {} | 1083 config_dict = {} |
1050 self.config_content = content | 1084 self.config_content = content |
1051 try: | 1085 try: |
1052 exec(content, config_dict) | 1086 exec(content, config_dict) |
1053 except SyntaxError, e: | 1087 except SyntaxError, e: |
1054 gclient_utils.SyntaxErrorToError('.gclient', e) | 1088 gclient_utils.SyntaxErrorToError('.gclient', e) |
1055 | 1089 |
1056 # Append any target OS that is not already being enforced to the tuple. | 1090 # Append any target OS that is not already being enforced to the tuple. |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 print(('\nWARNING: \'%s\' is no longer part of this client. ' | 1321 print(('\nWARNING: \'%s\' is no longer part of this client. ' |
1288 'It is recommended that you manually remove it.\n') % | 1322 'It is recommended that you manually remove it.\n') % |
1289 entry_fixed) | 1323 entry_fixed) |
1290 else: | 1324 else: |
1291 # Delete the entry | 1325 # Delete the entry |
1292 print('\n________ deleting \'%s\' in \'%s\'' % ( | 1326 print('\n________ deleting \'%s\' in \'%s\'' % ( |
1293 entry_fixed, self.root_dir)) | 1327 entry_fixed, self.root_dir)) |
1294 gclient_utils.rmtree(e_dir) | 1328 gclient_utils.rmtree(e_dir) |
1295 # record the current list of entries for next time | 1329 # record the current list of entries for next time |
1296 self._SaveEntries() | 1330 self._SaveEntries() |
| 1331 self._CheckConfig() |
1297 return 0 | 1332 return 0 |
1298 | 1333 |
1299 def PrintRevInfo(self): | 1334 def PrintRevInfo(self): |
1300 if not self.dependencies: | 1335 if not self.dependencies: |
1301 raise gclient_utils.Error('No solution specified') | 1336 raise gclient_utils.Error('No solution specified') |
1302 # Load all the settings. | 1337 # Load all the settings. |
1303 work_queue = gclient_utils.ExecutionQueue(self._options.jobs, None, False) | 1338 work_queue = gclient_utils.ExecutionQueue(self._options.jobs, None, False) |
1304 for s in self.dependencies: | 1339 for s in self.dependencies: |
1305 work_queue.enqueue(s) | 1340 work_queue.enqueue(s) |
1306 work_queue.flush({}, None, [], options=self._options) | 1341 work_queue.flush({}, None, [], options=self._options) |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 raise | 1956 raise |
1922 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1957 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1923 print >> sys.stderr, 'Error: %s' % str(e) | 1958 print >> sys.stderr, 'Error: %s' % str(e) |
1924 return 1 | 1959 return 1 |
1925 | 1960 |
1926 | 1961 |
1927 if '__main__' == __name__: | 1962 if '__main__' == __name__: |
1928 sys.exit(Main(sys.argv[1:])) | 1963 sys.exit(Main(sys.argv[1:])) |
1929 | 1964 |
1930 # vim: ts=2:sw=2:tw=80:et: | 1965 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |