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

Side by Side Diff: gclient.py

Issue 8994016: [depot_tools] Disabling new git checkouts with safesync_urls until fixed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: code review nit Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 7
8 Files 8 Files
9 .gclient : Current client configuration, written by 'config' command. 9 .gclient : Current client configuration, written by 'config' command.
10 Format is a Python script defining 'solutions', a list whose 10 Format is a Python script defining 'solutions', a list whose
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 """Checks for revision overrides.""" 913 """Checks for revision overrides."""
914 revision_overrides = {} 914 revision_overrides = {}
915 if self._options.head: 915 if self._options.head:
916 return revision_overrides 916 return revision_overrides
917 # Do not check safesync_url if one or more --revision flag is specified. 917 # Do not check safesync_url if one or more --revision flag is specified.
918 if not self._options.revisions: 918 if not self._options.revisions:
919 for s in self.dependencies: 919 for s in self.dependencies:
920 if not s.managed: 920 if not s.managed:
921 self._options.revisions.append('%s@unmanaged' % s.name) 921 self._options.revisions.append('%s@unmanaged' % s.name)
922 elif s.safesync_url: 922 elif s.safesync_url:
923 handle = urllib.urlopen(s.safesync_url) 923 self._ApplySafeSyncRev(dep=s)
924 rev = handle.read().strip()
925 handle.close()
926 scm = gclient_scm.CreateSCM(s.url, s.root.root_dir, s.name)
927 safe_rev = scm.GetUsableRev(rev=rev, options=self._options)
928 if not safe_rev:
929 raise gclient_utils.Error(
930 'Despite our best attempts, we couldn\'t find a useful\n'
931 'safesync_url revision for you.')
932 if self._options.verbose:
933 print('Using safesync_url revision: %s.\n' % safe_rev)
934 self._options.revisions.append('%s@%s' % (s.name, safe_rev))
935 if not self._options.revisions: 924 if not self._options.revisions:
936 return revision_overrides 925 return revision_overrides
937 solutions_names = [s.name for s in self.dependencies] 926 solutions_names = [s.name for s in self.dependencies]
938 index = 0 927 index = 0
939 for revision in self._options.revisions: 928 for revision in self._options.revisions:
940 if not '@' in revision: 929 if not '@' in revision:
941 # Support for --revision 123 930 # Support for --revision 123
942 revision = '%s@%s' % (solutions_names[index], revision) 931 revision = '%s@%s' % (solutions_names[index], revision)
943 sol, rev = revision.split('@', 1) 932 sol, rev = revision.split('@', 1)
944 if not sol in solutions_names: 933 if not sol in solutions_names:
945 #raise gclient_utils.Error('%s is not a valid solution.' % sol) 934 #raise gclient_utils.Error('%s is not a valid solution.' % sol)
946 print >> sys.stderr, ('Please fix your script, having invalid ' 935 print >> sys.stderr, ('Please fix your script, having invalid '
947 '--revision flags will soon considered an error.') 936 '--revision flags will soon considered an error.')
948 else: 937 else:
949 revision_overrides[sol] = rev 938 revision_overrides[sol] = rev
950 index += 1 939 index += 1
951 return revision_overrides 940 return revision_overrides
952 941
942 def _ApplySafeSyncRev(self, dep):
943 """Finds a valid revision from the content of the safesync_url and apply it
944 by appending revisions to the revision list. Throws if revision appears to
945 be invalid for the given |dep|."""
946 assert len(dep.safesync_url) > 0
947 handle = urllib.urlopen(dep.safesync_url)
948 rev = handle.read().strip()
949 handle.close()
950 if not rev:
951 raise gclient_utils.Error(
952 'It appears your safesync_url (%s) is not working properly\n'
953 '(as it returned an empty response). Check your config.' %
954 dep.safesync_url)
955 scm = gclient_scm.CreateSCM(dep.url, dep.root.root_dir, dep.name)
956 safe_rev = scm.GetUsableRev(rev=rev, options=self._options)
957 if self._options.verbose:
958 print('Using safesync_url revision: %s.\n' % safe_rev)
959 self._options.revisions.append('%s@%s' % (dep.name, safe_rev))
960
953 def RunOnDeps(self, command, args): 961 def RunOnDeps(self, command, args):
954 """Runs a command on each dependency in a client and its dependencies. 962 """Runs a command on each dependency in a client and its dependencies.
955 963
956 Args: 964 Args:
957 command: The command to use (e.g., 'status' or 'diff') 965 command: The command to use (e.g., 'status' or 'diff')
958 args: list of str - extra arguments to add to the command line. 966 args: list of str - extra arguments to add to the command line.
959 """ 967 """
960 if not self.dependencies: 968 if not self.dependencies:
961 raise gclient_utils.Error('No solution specified') 969 raise gclient_utils.Error('No solution specified')
962 revision_overrides = self._EnforceRevisions() 970 revision_overrides = self._EnforceRevisions()
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1532 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1525 print >> sys.stderr, 'Error: %s' % str(e) 1533 print >> sys.stderr, 'Error: %s' % str(e)
1526 return 1 1534 return 1
1527 1535
1528 1536
1529 if '__main__' == __name__: 1537 if '__main__' == __name__:
1530 fix_encoding.fix_encoding() 1538 fix_encoding.fix_encoding()
1531 sys.exit(Main(sys.argv[1:])) 1539 sys.exit(Main(sys.argv[1:]))
1532 1540
1533 # vim: ts=2:sw=2:tw=80:et: 1541 # 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