| 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 |
| 11 import os | 11 import os |
| 12 import posixpath | 12 import posixpath |
| 13 import re | 13 import re |
| 14 import sys | 14 import sys |
| 15 import tempfile | 15 import tempfile |
| 16 import traceback | 16 import traceback |
| 17 import urlparse | 17 import urlparse |
| 18 | 18 |
| 19 import download_from_google_storage | 19 import download_from_google_storage |
| 20 import gclient_utils | 20 import gclient_utils |
| 21 import git_cache | 21 import git_cache |
| 22 import scm | 22 import scm |
| 23 import shutil | 23 import shutil |
| 24 import subprocess2 | 24 import subprocess2 |
| 25 import subprocess42 |
| 25 | 26 |
| 26 | 27 |
| 27 THIS_FILE_PATH = os.path.abspath(__file__) | 28 THIS_FILE_PATH = os.path.abspath(__file__) |
| 28 | 29 |
| 29 GSUTIL_DEFAULT_PATH = os.path.join( | 30 GSUTIL_DEFAULT_PATH = os.path.join( |
| 30 os.path.dirname(os.path.abspath(__file__)), 'gsutil.py') | 31 os.path.dirname(os.path.abspath(__file__)), 'gsutil.py') |
| 31 | 32 |
| 32 | 33 |
| 33 class NoUsableRevError(gclient_utils.Error): | 34 class NoUsableRevError(gclient_utils.Error): |
| 34 """Raised if requested revision isn't found in checkout.""" | 35 """Raised if requested revision isn't found in checkout.""" |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 # Handles an SVN rev. As an optimization, only verify an SVN revision as | 820 # Handles an SVN rev. As an optimization, only verify an SVN revision as |
| 820 # [0-9]{1,6} for now to avoid making a network request. | 821 # [0-9]{1,6} for now to avoid making a network request. |
| 821 if scm.GIT.IsGitSvn(cwd=self.checkout_path): | 822 if scm.GIT.IsGitSvn(cwd=self.checkout_path): |
| 822 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) | 823 local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) |
| 823 if not local_head or local_head < int(rev): | 824 if not local_head or local_head < int(rev): |
| 824 try: | 825 try: |
| 825 logging.debug('Looking for git-svn configuration optimizations.') | 826 logging.debug('Looking for git-svn configuration optimizations.') |
| 826 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 827 if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
| 827 cwd=self.checkout_path): | 828 cwd=self.checkout_path): |
| 828 self._Fetch(options) | 829 self._Fetch(options) |
| 829 except subprocess2.CalledProcessError: | 830 except (subprocess2.CalledProcessError, |
| 831 subprocess42.CalledProcessError): |
| 830 logging.debug('git config --get svn-remote.svn.fetch failed, ' | 832 logging.debug('git config --get svn-remote.svn.fetch failed, ' |
| 831 'ignoring possible optimization.') | 833 'ignoring possible optimization.') |
| 832 if options.verbose: | 834 if options.verbose: |
| 833 self.Print('Running git svn fetch. This might take a while.\n') | 835 self.Print('Running git svn fetch. This might take a while.\n') |
| 834 scm.GIT.Capture(['svn', 'fetch'], cwd=self.checkout_path) | 836 scm.GIT.Capture(['svn', 'fetch'], cwd=self.checkout_path) |
| 835 try: | 837 try: |
| 836 sha1 = scm.GIT.GetBlessedSha1ForSvnRev( | 838 sha1 = scm.GIT.GetBlessedSha1ForSvnRev( |
| 837 cwd=self.checkout_path, rev=rev) | 839 cwd=self.checkout_path, rev=rev) |
| 838 except gclient_utils.Error, e: | 840 except gclient_utils.Error, e: |
| 839 sha1 = e.message | 841 sha1 = e.message |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 remote or self.remote, | 1208 remote or self.remote, |
| 1207 ] | 1209 ] |
| 1208 | 1210 |
| 1209 if prune: | 1211 if prune: |
| 1210 fetch_cmd.append('--prune') | 1212 fetch_cmd.append('--prune') |
| 1211 if options.verbose: | 1213 if options.verbose: |
| 1212 fetch_cmd.append('--verbose') | 1214 fetch_cmd.append('--verbose') |
| 1213 elif quiet: | 1215 elif quiet: |
| 1214 fetch_cmd.append('--quiet') | 1216 fetch_cmd.append('--quiet') |
| 1215 self._Run(fetch_cmd, options, show_header=options.verbose, retry=True, | 1217 self._Run(fetch_cmd, options, show_header=options.verbose, retry=True, |
| 1216 kill_timeout=kill_timeout) | 1218 kill_timeout=kill_timeout, use_v42=True) |
| 1217 | 1219 |
| 1218 # Return the revision that was fetched; this will be stored in 'FETCH_HEAD' | 1220 # Return the revision that was fetched; this will be stored in 'FETCH_HEAD' |
| 1219 return self._Capture(['rev-parse', '--verify', 'FETCH_HEAD']) | 1221 return self._Capture(['rev-parse', '--verify', 'FETCH_HEAD']) |
| 1220 | 1222 |
| 1221 def _UpdateBranchHeads(self, options, fetch=False): | 1223 def _UpdateBranchHeads(self, options, fetch=False): |
| 1222 """Adds, and optionally fetches, "branch-heads" and "tags" refspecs | 1224 """Adds, and optionally fetches, "branch-heads" and "tags" refspecs |
| 1223 if requested.""" | 1225 if requested.""" |
| 1224 need_fetch = fetch | 1226 need_fetch = fetch |
| 1225 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: | 1227 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: |
| 1226 config_cmd = ['config', 'remote.%s.fetch' % self.remote, | 1228 config_cmd = ['config', 'remote.%s.fetch' % self.remote, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1241 # Disable 'unused options' warning | pylint: disable=W0613 | 1243 # Disable 'unused options' warning | pylint: disable=W0613 |
| 1242 kwargs.setdefault('cwd', self.checkout_path) | 1244 kwargs.setdefault('cwd', self.checkout_path) |
| 1243 kwargs.setdefault('stdout', self.out_fh) | 1245 kwargs.setdefault('stdout', self.out_fh) |
| 1244 kwargs['filter_fn'] = self.filter | 1246 kwargs['filter_fn'] = self.filter |
| 1245 kwargs.setdefault('print_stdout', False) | 1247 kwargs.setdefault('print_stdout', False) |
| 1246 env = scm.GIT.ApplyEnvVars(kwargs) | 1248 env = scm.GIT.ApplyEnvVars(kwargs) |
| 1247 cmd = ['git'] + args | 1249 cmd = ['git'] + args |
| 1248 if show_header: | 1250 if show_header: |
| 1249 gclient_utils.CheckCallAndFilterAndHeader(cmd, env=env, **kwargs) | 1251 gclient_utils.CheckCallAndFilterAndHeader(cmd, env=env, **kwargs) |
| 1250 else: | 1252 else: |
| 1251 gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs) | 1253 if kwargs.pop('use_v42', False): |
| 1254 gclient_utils.CheckCallAndFilter42(cmd, env=env, **kwargs) |
| 1255 else: |
| 1256 gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs) |
| 1252 | 1257 |
| 1253 | 1258 |
| 1254 class SVNWrapper(SCMWrapper): | 1259 class SVNWrapper(SCMWrapper): |
| 1255 """ Wrapper for SVN """ | 1260 """ Wrapper for SVN """ |
| 1256 name = 'svn' | 1261 name = 'svn' |
| 1257 _PRINTED_DEPRECATION = False | 1262 _PRINTED_DEPRECATION = False |
| 1258 | 1263 |
| 1259 _MESSAGE = ( | 1264 _MESSAGE = ( |
| 1260 'Oh hai! You are using subversion. Chrome infra is eager to get rid of', | 1265 'Oh hai! You are using subversion. Chrome infra is eager to get rid of', |
| 1261 'svn support so please switch to git.', | 1266 'svn support so please switch to git.', |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 new_command.append('--force') | 1734 new_command.append('--force') |
| 1730 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1735 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1731 new_command.extend(('--accept', 'theirs-conflict')) | 1736 new_command.extend(('--accept', 'theirs-conflict')) |
| 1732 elif options.manually_grab_svn_rev: | 1737 elif options.manually_grab_svn_rev: |
| 1733 new_command.append('--force') | 1738 new_command.append('--force') |
| 1734 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1739 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1735 new_command.extend(('--accept', 'postpone')) | 1740 new_command.extend(('--accept', 'postpone')) |
| 1736 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1741 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1737 new_command.extend(('--accept', 'postpone')) | 1742 new_command.extend(('--accept', 'postpone')) |
| 1738 return new_command | 1743 return new_command |
| OLD | NEW |