Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: gclient.py

Issue 195913002: gclient: in managed mode, warn if .gclient has a mismatched URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Move _CheckConfig to end of RunOnDeps Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gclient_scm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 any existing checkout."""
iannucci 2014/03/18 20:20:56 """Verify that the .gclient file matches the state
borenet 2014/03/18 20:30:08 Done.
1049 for dep in self.dependencies:
1050 if dep.managed:
1051 scm = gclient_scm.CreateSCM(dep.url, self.root_dir, dep.name)
1052 actual_url = scm.GetActualRemoteURL()
1053 if actual_url and not scm.DoesRemoteURLMatch():
1054 print >> sys.stderr, ('''
1055 ################################################################################
1056 ################################### WARNING! ###################################
1057 ################################################################################
1058
1059 Your .gclient file seems to be broken. The requested URL is different from what
1060 is actually checked out in %(checkout_path)s. In the future this will be an
1061 error.
1062
1063 Expected: %(expected_url)s (%(expected_scm)s)
1064 Actual: %(actual_url)s (%(actual_scm)s)
1065
1066 You should ensure that the URL listed in .gclient is correct and either change
1067 it or fix the checkout. If you're managing your own git checkout in
1068 %(checkout_path)s but the URL in .gclient is for an svn repository, you probably
1069 want to set 'managed': False in .gclient.
1070
1071 ################################################################################
1072 ################################################################################
1073 ################################################################################
1074 ''' % {'checkout_path': os.path.join(self.root_dir, dep.name),
1075 'expected_url': dep.url,
1076 'expected_scm': gclient_scm.GetScmName(dep.url),
1077 'actual_url': actual_url,
1078 'actual_scm': gclient_scm.GetScmName(actual_url)})
1079
1047 def SetConfig(self, content): 1080 def SetConfig(self, content):
1048 assert not self.dependencies 1081 assert not self.dependencies
1049 config_dict = {} 1082 config_dict = {}
1050 self.config_content = content 1083 self.config_content = content
1051 try: 1084 try:
1052 exec(content, config_dict) 1085 exec(content, config_dict)
1053 except SyntaxError, e: 1086 except SyntaxError, e:
1054 gclient_utils.SyntaxErrorToError('.gclient', e) 1087 gclient_utils.SyntaxErrorToError('.gclient', e)
1055 1088
1056 # Append any target OS that is not already being enforced to the tuple. 1089 # 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
1287 print(('\nWARNING: \'%s\' is no longer part of this client. ' 1320 print(('\nWARNING: \'%s\' is no longer part of this client. '
1288 'It is recommended that you manually remove it.\n') % 1321 'It is recommended that you manually remove it.\n') %
1289 entry_fixed) 1322 entry_fixed)
1290 else: 1323 else:
1291 # Delete the entry 1324 # Delete the entry
1292 print('\n________ deleting \'%s\' in \'%s\'' % ( 1325 print('\n________ deleting \'%s\' in \'%s\'' % (
1293 entry_fixed, self.root_dir)) 1326 entry_fixed, self.root_dir))
1294 gclient_utils.rmtree(e_dir) 1327 gclient_utils.rmtree(e_dir)
1295 # record the current list of entries for next time 1328 # record the current list of entries for next time
1296 self._SaveEntries() 1329 self._SaveEntries()
1330 self._CheckConfig()
1297 return 0 1331 return 0
1298 1332
1299 def PrintRevInfo(self): 1333 def PrintRevInfo(self):
1300 if not self.dependencies: 1334 if not self.dependencies:
1301 raise gclient_utils.Error('No solution specified') 1335 raise gclient_utils.Error('No solution specified')
1302 # Load all the settings. 1336 # Load all the settings.
1303 work_queue = gclient_utils.ExecutionQueue(self._options.jobs, None, False) 1337 work_queue = gclient_utils.ExecutionQueue(self._options.jobs, None, False)
1304 for s in self.dependencies: 1338 for s in self.dependencies:
1305 work_queue.enqueue(s) 1339 work_queue.enqueue(s)
1306 work_queue.flush({}, None, [], options=self._options) 1340 work_queue.flush({}, None, [], options=self._options)
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 raise 1955 raise
1922 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1956 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1923 print >> sys.stderr, 'Error: %s' % str(e) 1957 print >> sys.stderr, 'Error: %s' % str(e)
1924 return 1 1958 return 1
1925 1959
1926 1960
1927 if '__main__' == __name__: 1961 if '__main__' == __name__:
1928 sys.exit(Main(sys.argv[1:])) 1962 sys.exit(Main(sys.argv[1:]))
1929 1963
1930 # vim: ts=2:sw=2:tw=80:et: 1964 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | gclient_scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698