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 logging | 9 import logging |
10 import os | 10 import os |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 command, self.__class__.__name__)) | 155 command, self.__class__.__name__)) |
156 | 156 |
157 return getattr(self, command)(options, args, file_list) | 157 return getattr(self, command)(options, args, file_list) |
158 | 158 |
159 def GetActualRemoteURL(self, options): | 159 def GetActualRemoteURL(self, options): |
160 """Attempt to determine the remote URL for this SCMWrapper.""" | 160 """Attempt to determine the remote URL for this SCMWrapper.""" |
161 # Git | 161 # Git |
162 if os.path.exists(os.path.join(self.checkout_path, '.git')): | 162 if os.path.exists(os.path.join(self.checkout_path, '.git')): |
163 actual_remote_url = shlex.split(self._Capture( | 163 actual_remote_url = shlex.split(self._Capture( |
164 ['config', '--local', '--get-regexp', r'remote.*.url'], | 164 ['config', '--local', '--get-regexp', r'remote.*.url'], |
165 self.checkout_path))[1] | 165 cwd=self.checkout_path))[1] |
166 | 166 |
167 # If a cache_dir is used, obtain the actual remote URL from the cache. | 167 # If a cache_dir is used, obtain the actual remote URL from the cache. |
168 if getattr(self, 'cache_dir', None): | 168 if getattr(self, 'cache_dir', None): |
169 mirror = git_cache.Mirror(self.url) | 169 mirror = git_cache.Mirror(self.url) |
170 if (mirror.exists() and mirror.mirror_path.replace('\\', '/') == | 170 if (mirror.exists() and mirror.mirror_path.replace('\\', '/') == |
171 actual_remote_url.replace('\\', '/')): | 171 actual_remote_url.replace('\\', '/')): |
172 actual_remote_url = shlex.split(self._Capture( | 172 actual_remote_url = shlex.split(self._Capture( |
173 ['config', '--local', '--get-regexp', r'remote.*.url'], | 173 ['config', '--local', '--get-regexp', r'remote.*.url'], |
174 cwd=mirror.mirror_path))[1] | 174 cwd=mirror.mirror_path))[1] |
175 return actual_remote_url | 175 return actual_remote_url |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 self.Print('_____ found an unreferenced commit and saved it as \'%s\'' % | 941 self.Print('_____ found an unreferenced commit and saved it as \'%s\'' % |
942 name) | 942 name) |
943 | 943 |
944 def _GetCurrentBranch(self): | 944 def _GetCurrentBranch(self): |
945 # Returns name of current branch or None for detached HEAD | 945 # Returns name of current branch or None for detached HEAD |
946 branch = self._Capture(['rev-parse', '--abbrev-ref=strict', 'HEAD']) | 946 branch = self._Capture(['rev-parse', '--abbrev-ref=strict', 'HEAD']) |
947 if branch == 'HEAD': | 947 if branch == 'HEAD': |
948 return None | 948 return None |
949 return branch | 949 return branch |
950 | 950 |
951 def _Capture(self, args, cwd=None, **kwargs): | 951 def _Capture(self, args, **kwargs): |
952 kwargs.setdefault('cwd', self.checkout_path) | 952 kwargs.setdefault('cwd', self.checkout_path) |
953 kwargs.setdefault('stderr', subprocess2.PIPE) | 953 kwargs.setdefault('stderr', subprocess2.PIPE) |
954 return subprocess2.check_output(['git'] + args, **kwargs).strip() | 954 return subprocess2.check_output(['git'] + args, **kwargs).strip() |
955 | 955 |
956 def _UpdateBranchHeads(self, options, fetch=False): | 956 def _UpdateBranchHeads(self, options, fetch=False): |
957 """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" | 957 """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" |
958 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: | 958 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: |
959 config_cmd = ['config', 'remote.%s.fetch' % self.remote, | 959 config_cmd = ['config', 'remote.%s.fetch' % self.remote, |
960 '+refs/branch-heads/*:refs/remotes/branch-heads/*', | 960 '+refs/branch-heads/*:refs/remotes/branch-heads/*', |
961 '^\\+refs/branch-heads/\\*:.*$'] | 961 '^\\+refs/branch-heads/\\*:.*$'] |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 new_command.append('--force') | 1452 new_command.append('--force') |
1453 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1453 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1454 new_command.extend(('--accept', 'theirs-conflict')) | 1454 new_command.extend(('--accept', 'theirs-conflict')) |
1455 elif options.manually_grab_svn_rev: | 1455 elif options.manually_grab_svn_rev: |
1456 new_command.append('--force') | 1456 new_command.append('--force') |
1457 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1457 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1458 new_command.extend(('--accept', 'postpone')) | 1458 new_command.extend(('--accept', 'postpone')) |
1459 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1459 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1460 new_command.extend(('--accept', 'postpone')) | 1460 new_command.extend(('--accept', 'postpone')) |
1461 return new_command | 1461 return new_command |
OLD | NEW |