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

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: Add GetActualRemoteURL and DoesRemoteURLMatch to SCMWrapper 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') | gclient_scm.py » ('J')
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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1213
1214 def RunOnDeps(self, command, args, ignore_requirements=False, progress=True): 1214 def RunOnDeps(self, command, args, ignore_requirements=False, progress=True):
1215 """Runs a command on each dependency in a client and its dependencies. 1215 """Runs a command on each dependency in a client and its dependencies.
1216 1216
1217 Args: 1217 Args:
1218 command: The command to use (e.g., 'status' or 'diff') 1218 command: The command to use (e.g., 'status' or 'diff')
1219 args: list of str - extra arguments to add to the command line. 1219 args: list of str - extra arguments to add to the command line.
1220 """ 1220 """
1221 if not self.dependencies: 1221 if not self.dependencies:
1222 raise gclient_utils.Error('No solution specified') 1222 raise gclient_utils.Error('No solution specified')
1223
1224 for dep in self.dependencies:
1225 if dep.managed:
1226 scm = gclient_scm.CreateSCM(dep.url, self.root_dir, dep.name)
1227 if not scm.DoesRemoteURLMatch():
1228 actual_url = scm.GetActualRemoteURL()
1229 raise gclient_utils.Error('''
1230 Your .gclient file seems to be broken. The requested URL is different from what
1231 is actually checked out in %s:
1232
1233 Expected: %s
1234 Actual: %s
iannucci 2014/03/13 18:27:27 I would also list the SCM which we would have sele
borenet 2014/03/13 18:57:25 Done.
1235
1236 If you're managing your own git checkout in %s but the URL in .gclient is for
1237 an svn repository, you probably want to set 'managed': False in .gclient.
iannucci 2014/03/13 18:27:27 do we also want to advise that they correct the ur
borenet 2014/03/13 18:57:25 Sure, but the URL doesn't matter in unmanaged mode
1238 Otherwise, you should ensure that the URL listed in .gclient is correct and
1239 either change it or fix the checkout.
1240 ''' % (os.path.join(self.root_dir, dep.name), dep.url, actual_url, dep.name))
1241
1223 revision_overrides = {} 1242 revision_overrides = {}
1224 # It's unnecessary to check for revision overrides for 'recurse'. 1243 # It's unnecessary to check for revision overrides for 'recurse'.
1225 # Save a few seconds by not calling _EnforceRevisions() in that case. 1244 # Save a few seconds by not calling _EnforceRevisions() in that case.
1226 if command not in ('diff', 'recurse', 'runhooks', 'status'): 1245 if command not in ('diff', 'recurse', 'runhooks', 'status'):
1227 revision_overrides = self._EnforceRevisions() 1246 revision_overrides = self._EnforceRevisions()
1228 pm = None 1247 pm = None
1229 # Disable progress for non-tty stdout. 1248 # Disable progress for non-tty stdout.
1230 if (sys.stdout.isatty() and not self._options.verbose and progress): 1249 if (sys.stdout.isatty() and not self._options.verbose and progress):
1231 if command in ('update', 'revert'): 1250 if command in ('update', 'revert'):
1232 pm = Progress('Syncing projects', 1) 1251 pm = Progress('Syncing projects', 1)
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 raise gclient_utils.Error('client not configured; see \'gclient config\'') 1706 raise gclient_utils.Error('client not configured; see \'gclient config\'')
1688 1707
1689 if options.revisions and options.head: 1708 if options.revisions and options.head:
1690 # TODO(maruel): Make it a parser.error if it doesn't break any builder. 1709 # TODO(maruel): Make it a parser.error if it doesn't break any builder.
1691 print('Warning: you cannot use both --head and --revision') 1710 print('Warning: you cannot use both --head and --revision')
1692 1711
1693 if options.verbose: 1712 if options.verbose:
1694 # Print out the .gclient file. This is longer than if we just printed the 1713 # Print out the .gclient file. This is longer than if we just printed the
1695 # client dict, but more legible, and it might contain helpful comments. 1714 # client dict, but more legible, and it might contain helpful comments.
1696 print(client.config_content) 1715 print(client.config_content)
1716
1697 ret = client.RunOnDeps('update', args) 1717 ret = client.RunOnDeps('update', args)
1698 if options.output_json: 1718 if options.output_json:
1699 slns = {} 1719 slns = {}
1700 for d in client.subtree(True): 1720 for d in client.subtree(True):
1701 normed = d.name.replace('\\', '/').rstrip('/') + '/' 1721 normed = d.name.replace('\\', '/').rstrip('/') + '/'
1702 slns[normed] = { 1722 slns[normed] = {
1703 'revision': d.got_revision, 1723 'revision': d.got_revision,
1704 'scm': d.used_scm.name if d.used_scm else None, 1724 'scm': d.used_scm.name if d.used_scm else None,
1705 } 1725 }
1706 with open(options.output_json, 'wb') as f: 1726 with open(options.output_json, 'wb') as f:
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 raise 1941 raise
1922 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1942 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1923 print >> sys.stderr, 'Error: %s' % str(e) 1943 print >> sys.stderr, 'Error: %s' % str(e)
1924 return 1 1944 return 1
1925 1945
1926 1946
1927 if '__main__' == __name__: 1947 if '__main__' == __name__:
1928 sys.exit(Main(sys.argv[1:])) 1948 sys.exit(Main(sys.argv[1:]))
1929 1949
1930 # vim: ts=2:sw=2:tw=80:et: 1950 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | gclient_scm.py » ('j') | gclient_scm.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698