| 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 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import posixpath | 9 import posixpath |
| 10 import re | 10 import re |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 gclient_utils.CheckCallAndFilter(cmd4, **kwargs) | 249 gclient_utils.CheckCallAndFilter(cmd4, **kwargs) |
| 250 | 250 |
| 251 def _FetchAndReset(self, revision, file_list, options): | 251 def _FetchAndReset(self, revision, file_list, options): |
| 252 """Equivalent to git fetch; git reset.""" | 252 """Equivalent to git fetch; git reset.""" |
| 253 quiet = [] | 253 quiet = [] |
| 254 if not options.verbose: | 254 if not options.verbose: |
| 255 quiet = ['--quiet'] | 255 quiet = ['--quiet'] |
| 256 self._UpdateBranchHeads(options, fetch=False) | 256 self._UpdateBranchHeads(options, fetch=False) |
| 257 | 257 |
| 258 cfg = gclient_utils.DefaultIndexPackConfig() | 258 cfg = gclient_utils.DefaultIndexPackConfig(self.url) |
| 259 fetch_cmd = cfg + ['fetch', self.remote, '--prune'] | 259 fetch_cmd = cfg + ['fetch', self.remote, '--prune'] |
| 260 self._Run(fetch_cmd + quiet, options, retry=True) | 260 self._Run(fetch_cmd + quiet, options, retry=True) |
| 261 self._Run(['reset', '--hard', revision] + quiet, options) | 261 self._Run(['reset', '--hard', revision] + quiet, options) |
| 262 self.UpdateSubmoduleConfig() | 262 self.UpdateSubmoduleConfig() |
| 263 if file_list is not None: | 263 if file_list is not None: |
| 264 files = self._Capture(['ls-files']).splitlines() | 264 files = self._Capture(['ls-files']).splitlines() |
| 265 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 265 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 266 | 266 |
| 267 def update(self, options, args, file_list): | 267 def update(self, options, args, file_list): |
| 268 """Runs git to update or transparently checkout the working copy. | 268 """Runs git to update or transparently checkout the working copy. |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 revision is a branch head. If it is a tag or a specific commit, then we | 718 revision is a branch head. If it is a tag or a specific commit, then we |
| 719 leave HEAD detached as it makes future updates simpler -- in this case the | 719 leave HEAD detached as it makes future updates simpler -- in this case the |
| 720 user should first create a new branch or switch to an existing branch before | 720 user should first create a new branch or switch to an existing branch before |
| 721 making changes in the repo.""" | 721 making changes in the repo.""" |
| 722 if not options.verbose: | 722 if not options.verbose: |
| 723 # git clone doesn't seem to insert a newline properly before printing | 723 # git clone doesn't seem to insert a newline properly before printing |
| 724 # to stdout | 724 # to stdout |
| 725 print('') | 725 print('') |
| 726 template_path = os.path.join( | 726 template_path = os.path.join( |
| 727 os.path.dirname(THIS_FILE_PATH), 'git-templates') | 727 os.path.dirname(THIS_FILE_PATH), 'git-templates') |
| 728 cfg = gclient_utils.DefaultIndexPackConfig() | 728 cfg = gclient_utils.DefaultIndexPackConfig(self.url) |
| 729 clone_cmd = cfg + [ | 729 clone_cmd = cfg + [ |
| 730 'clone', '--no-checkout', '--progress', '--template=%s' % template_path] | 730 'clone', '--no-checkout', '--progress', '--template=%s' % template_path] |
| 731 if self.cache_dir: | 731 if self.cache_dir: |
| 732 clone_cmd.append('--shared') | 732 clone_cmd.append('--shared') |
| 733 if options.verbose: | 733 if options.verbose: |
| 734 clone_cmd.append('--verbose') | 734 clone_cmd.append('--verbose') |
| 735 clone_cmd.append(url) | 735 clone_cmd.append(url) |
| 736 # If the parent directory does not exist, Git clone on Windows will not | 736 # If the parent directory does not exist, Git clone on Windows will not |
| 737 # create it, so we need to do it manually. | 737 # create it, so we need to do it manually. |
| 738 parent_dir = os.path.dirname(self.checkout_path) | 738 parent_dir = os.path.dirname(self.checkout_path) |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 cwd=cwd or self.checkout_path).strip() | 930 cwd=cwd or self.checkout_path).strip() |
| 931 | 931 |
| 932 def _UpdateBranchHeads(self, options, fetch=False): | 932 def _UpdateBranchHeads(self, options, fetch=False): |
| 933 """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" | 933 """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" |
| 934 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: | 934 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: |
| 935 config_cmd = ['config', 'remote.%s.fetch' % self.remote, | 935 config_cmd = ['config', 'remote.%s.fetch' % self.remote, |
| 936 '+refs/branch-heads/*:refs/remotes/branch-heads/*', | 936 '+refs/branch-heads/*:refs/remotes/branch-heads/*', |
| 937 '^\\+refs/branch-heads/\\*:.*$'] | 937 '^\\+refs/branch-heads/\\*:.*$'] |
| 938 self._Run(config_cmd, options) | 938 self._Run(config_cmd, options) |
| 939 if fetch: | 939 if fetch: |
| 940 cfg = gclient_utils.DefaultIndexPackConfig() | 940 cfg = gclient_utils.DefaultIndexPackConfig(self.url) |
| 941 fetch_cmd = cfg + ['fetch', self.remote] | 941 fetch_cmd = cfg + ['fetch', self.remote] |
| 942 if options.verbose: | 942 if options.verbose: |
| 943 fetch_cmd.append('--verbose') | 943 fetch_cmd.append('--verbose') |
| 944 self._Run(fetch_cmd, options, retry=True) | 944 self._Run(fetch_cmd, options, retry=True) |
| 945 | 945 |
| 946 def _Run(self, args, options, **kwargs): | 946 def _Run(self, args, options, **kwargs): |
| 947 kwargs.setdefault('cwd', self.checkout_path) | 947 kwargs.setdefault('cwd', self.checkout_path) |
| 948 git_filter = not options.verbose | 948 git_filter = not options.verbose |
| 949 if git_filter: | 949 if git_filter: |
| 950 kwargs['filter_fn'] = gclient_utils.GitFilter(kwargs.get('filter_fn')) | 950 kwargs['filter_fn'] = gclient_utils.GitFilter(kwargs.get('filter_fn')) |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 new_command.append('--force') | 1427 new_command.append('--force') |
| 1428 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1428 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1429 new_command.extend(('--accept', 'theirs-conflict')) | 1429 new_command.extend(('--accept', 'theirs-conflict')) |
| 1430 elif options.manually_grab_svn_rev: | 1430 elif options.manually_grab_svn_rev: |
| 1431 new_command.append('--force') | 1431 new_command.append('--force') |
| 1432 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1432 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1433 new_command.extend(('--accept', 'postpone')) | 1433 new_command.extend(('--accept', 'postpone')) |
| 1434 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1434 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1435 new_command.extend(('--accept', 'postpone')) | 1435 new_command.extend(('--accept', 'postpone')) |
| 1436 return new_command | 1436 return new_command |
| OLD | NEW |