OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
6 | 6 |
7 from __future__ import print_function | 7 from __future__ import print_function |
8 | 8 |
9 import errno | 9 import errno |
10 import logging | 10 import logging |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 stdout=self.out_fh, always=options.verbose) | 770 stdout=self.out_fh, always=options.verbose) |
771 if file_list is not None: | 771 if file_list is not None: |
772 files = self._Capture(['diff', '--name-only'] + merge_base).split() | 772 files = self._Capture(['diff', '--name-only'] + merge_base).split() |
773 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 773 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
774 | 774 |
775 def GetUsableRev(self, rev, options): | 775 def GetUsableRev(self, rev, options): |
776 """Finds a useful revision for this repository.""" | 776 """Finds a useful revision for this repository.""" |
777 sha1 = None | 777 sha1 = None |
778 if not os.path.isdir(self.checkout_path): | 778 if not os.path.isdir(self.checkout_path): |
779 raise NoUsableRevError( | 779 raise NoUsableRevError( |
780 ( 'We could not find a valid hash for safesync_url response "%s".\n' | 780 'This is not a git repo, so we cannot get a usable rev.') |
781 'Safesync URLs with a git checkout currently require the repo to\n' | |
782 'be cloned without a safesync_url before adding the safesync_url.\n' | |
783 'For more info, see: ' | |
784 'http://code.google.com/p/chromium/wiki/UsingNewGit' | |
785 '#Initial_checkout' ) % rev) | |
786 | 781 |
787 if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev): | 782 if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev): |
788 sha1 = rev | 783 sha1 = rev |
789 else: | 784 else: |
790 # May exist in origin, but we don't have it yet, so fetch and look | 785 # May exist in origin, but we don't have it yet, so fetch and look |
791 # again. | 786 # again. |
792 self._Fetch(options) | 787 self._Fetch(options) |
793 if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev): | 788 if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev): |
794 sha1 = rev | 789 sha1 = rev |
795 | 790 |
796 if not sha1: | 791 if not sha1: |
797 raise NoUsableRevError( | 792 raise NoUsableRevError( |
798 ('We could not find a valid hash for safesync_url response "%s".\n' | 793 'Hash %s does not appear to be a valid hash in this repo.' % rev) |
799 'Please ensure that your safesync_url provides git sha1 hashes.\n' | |
800 'For more info, see:\n' | |
801 'http://code.google.com/p/chromium/wiki/UsingNewGit#Initial_checkout' | |
802 ) % rev) | |
803 | 794 |
804 return sha1 | 795 return sha1 |
805 | 796 |
806 def FullUrlForRelativeUrl(self, url): | 797 def FullUrlForRelativeUrl(self, url): |
807 # Strip from last '/' | 798 # Strip from last '/' |
808 # Equivalent to unix basename | 799 # Equivalent to unix basename |
809 base_url = self.url | 800 base_url = self.url |
810 return base_url[:base_url.rfind('/')] + url | 801 return base_url[:base_url.rfind('/')] + url |
811 | 802 |
812 def GetGitBackupDirPath(self): | 803 def GetGitBackupDirPath(self): |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 kwargs.setdefault('cwd', self.checkout_path) | 1166 kwargs.setdefault('cwd', self.checkout_path) |
1176 kwargs.setdefault('stdout', self.out_fh) | 1167 kwargs.setdefault('stdout', self.out_fh) |
1177 kwargs['filter_fn'] = self.filter | 1168 kwargs['filter_fn'] = self.filter |
1178 kwargs.setdefault('print_stdout', False) | 1169 kwargs.setdefault('print_stdout', False) |
1179 env = scm.GIT.ApplyEnvVars(kwargs) | 1170 env = scm.GIT.ApplyEnvVars(kwargs) |
1180 cmd = ['git'] + args | 1171 cmd = ['git'] + args |
1181 if show_header: | 1172 if show_header: |
1182 gclient_utils.CheckCallAndFilterAndHeader(cmd, env=env, **kwargs) | 1173 gclient_utils.CheckCallAndFilterAndHeader(cmd, env=env, **kwargs) |
1183 else: | 1174 else: |
1184 gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs) | 1175 gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs) |
OLD | NEW |