Chromium Code Reviews| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 '\tTo resolve:\n' | 311 '\tTo resolve:\n' |
| 312 '\t\trm -rf %s\n' | 312 '\t\trm -rf %s\n' |
| 313 '\tAnd run gclient sync again\n' | 313 '\tAnd run gclient sync again\n' |
| 314 % (self.relpath, rev_str, self.relpath)) | 314 % (self.relpath, rev_str, self.relpath)) |
| 315 | 315 |
| 316 # See if the url has changed (the unittests use git://foo for the url, let | 316 # See if the url has changed (the unittests use git://foo for the url, let |
| 317 # that through). | 317 # that through). |
| 318 current_url = self._Capture(['config', 'remote.origin.url']) | 318 current_url = self._Capture(['config', 'remote.origin.url']) |
| 319 # TODO(maruel): Delete url != 'git://foo' since it's just to make the | 319 # TODO(maruel): Delete url != 'git://foo' since it's just to make the |
| 320 # unit test pass. (and update the comment above) | 320 # unit test pass. (and update the comment above) |
| 321 if (current_url != url and url != 'git://foo' and | 321 # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. |
| 322 self._Capture(['config', 'remote.origin.gclient']) != 'getoffmylawn'): | 322 # This allows devs to use experimental repos which have a different url |
| 323 # but whose branch(s) are the same as official repos. | |
| 324 if (current_url != url and | |
| 325 url != 'git://foo' and | |
| 326 subprocess2.capture( | |
| 327 ['git', 'config', 'remote.origin.gclient-auto-fix-url'], | |
| 328 cwd=self.checkout_path).strip() != 'False'): | |
| 323 print('_____ switching %s to a new upstream' % self.relpath) | 329 print('_____ switching %s to a new upstream' % self.relpath) |
| 324 # Make sure it's clean | 330 # Make sure it's clean |
| 325 self._CheckClean(rev_str) | 331 self._CheckClean(rev_str) |
| 326 # Switch over to the new upstream | 332 # Switch over to the new upstream |
| 327 self._Run(['remote', 'set-url', 'origin', url], options) | 333 self._Run(['remote', 'set-url', 'origin', url], options) |
| 328 quiet = [] | 334 quiet = [] |
| 329 if not options.verbose: | 335 if not options.verbose: |
| 330 quiet = ['--quiet'] | 336 quiet = ['--quiet'] |
| 331 self._UpdateBranchHeads(options, fetch=False) | 337 self._UpdateBranchHeads(options, fetch=False) |
| 332 self._Run(['fetch', 'origin', '--prune'] + quiet, options) | 338 self._Run(['fetch', 'origin', '--prune'] + quiet, options) |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 def _GetCurrentBranch(self): | 858 def _GetCurrentBranch(self): |
| 853 # Returns name of current branch or None for detached HEAD | 859 # Returns name of current branch or None for detached HEAD |
| 854 branch = self._Capture(['rev-parse', '--abbrev-ref=strict', 'HEAD']) | 860 branch = self._Capture(['rev-parse', '--abbrev-ref=strict', 'HEAD']) |
| 855 if branch == 'HEAD': | 861 if branch == 'HEAD': |
| 856 return None | 862 return None |
| 857 return branch | 863 return branch |
| 858 | 864 |
| 859 def _Capture(self, args): | 865 def _Capture(self, args): |
| 860 return subprocess2.check_output( | 866 return subprocess2.check_output( |
| 861 ['git'] + args, | 867 ['git'] + args, |
| 862 stderr=subprocess2.PIPE, | 868 stderr=subprocess2.VOID, |
|
Dirk Pranke
2013/05/22 00:05:15
why change this from PIPE to VOID ?
Isaac (away)
2013/05/22 00:12:25
This is an unrelated minor bug I spotted.
subproce
| |
| 863 nag_timer=self.nag_timer, | 869 nag_timer=self.nag_timer, |
| 864 nag_max=self.nag_max, | 870 nag_max=self.nag_max, |
| 865 cwd=self.checkout_path).strip() | 871 cwd=self.checkout_path).strip() |
| 866 | 872 |
| 867 def _UpdateBranchHeads(self, options, fetch=False): | 873 def _UpdateBranchHeads(self, options, fetch=False): |
| 868 """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" | 874 """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" |
| 869 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: | 875 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: |
| 870 backoff_time = 5 | 876 backoff_time = 5 |
| 871 for _ in range(3): | 877 for _ in range(3): |
| 872 try: | 878 try: |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1276 new_command.append('--force') | 1282 new_command.append('--force') |
| 1277 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1283 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1278 new_command.extend(('--accept', 'theirs-conflict')) | 1284 new_command.extend(('--accept', 'theirs-conflict')) |
| 1279 elif options.manually_grab_svn_rev: | 1285 elif options.manually_grab_svn_rev: |
| 1280 new_command.append('--force') | 1286 new_command.append('--force') |
| 1281 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1287 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1282 new_command.extend(('--accept', 'postpone')) | 1288 new_command.extend(('--accept', 'postpone')) |
| 1283 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1289 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1284 new_command.extend(('--accept', 'postpone')) | 1290 new_command.extend(('--accept', 'postpone')) |
| 1285 return new_command | 1291 return new_command |
| OLD | NEW |