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 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 url != 'git://foo' and | 449 url != 'git://foo' and |
| 450 subprocess2.capture( | 450 subprocess2.capture( |
| 451 ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote], | 451 ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote], |
| 452 cwd=self.checkout_path).strip() != 'False'): | 452 cwd=self.checkout_path).strip() != 'False'): |
| 453 self.Print('_____ switching %s to a new upstream' % self.relpath) | 453 self.Print('_____ switching %s to a new upstream' % self.relpath) |
| 454 if not (options.force or options.reset): | 454 if not (options.force or options.reset): |
| 455 # Make sure it's clean | 455 # Make sure it's clean |
| 456 self._CheckClean(rev_str) | 456 self._CheckClean(rev_str) |
| 457 # Switch over to the new upstream | 457 # Switch over to the new upstream |
| 458 self._Run(['remote', 'set-url', self.remote, url], options) | 458 self._Run(['remote', 'set-url', self.remote, url], options) |
| 459 self.Print("remote is set", revision, self.url) | |
| 459 if mirror: | 460 if mirror: |
| 460 with open(os.path.join( | 461 with open(os.path.join( |
| 461 self.checkout_path, '.git', 'objects', 'info', 'alternates'), | 462 self.checkout_path, '.git', 'objects', 'info', 'alternates'), |
| 462 'w') as fh: | 463 'w') as fh: |
| 463 fh.write(os.path.join(url, 'objects')) | 464 fh.write(os.path.join(url, 'objects')) |
| 465 try: | |
|
Adrian Kuegel
2015/08/21 15:41:16
Just a small nit: couldn't you put these lines int
| |
| 466 self._Capture(['rev-list', '-n', '1', 'HEAD']) | |
| 467 except subprocess2.CalledProcessError as e: | |
| 468 if ('fatal: bad object HEAD' in e.stderr | |
| 469 and self.cache_dir and self.cache_dir in url): | |
| 470 self.Print(( | |
| 471 'Likely due to DEPS change with git cache_dir, ' | |
| 472 'the current commit points to no longer existing object.\n' | |
| 473 '%s' % e) | |
| 474 ) | |
| 475 self._DeleteOrMove(options.force) | |
| 476 self._Clone(revision, url, options) | |
| 477 else: | |
| 478 raise | |
| 464 self._FetchAndReset(revision, file_list, options) | 479 self._FetchAndReset(revision, file_list, options) |
| 480 | |
| 465 return_early = True | 481 return_early = True |
| 482 else: | |
| 483 try: | |
| 484 self._Capture(['rev-list', '-n', '1', 'HEAD']) | |
| 485 except subprocess2.CalledProcessError as e: | |
| 486 if ('fatal: bad object HEAD' in e.stderr | |
| 487 and self.cache_dir and self.cache_dir in url): | |
| 488 self.Print(( | |
| 489 'Likely due to DEPS change with git cache_dir, ' | |
| 490 'the current commit points to no longer existing object.\n' | |
| 491 '%s' % e) | |
| 492 ) | |
| 493 self._DeleteOrMove(options.force) | |
| 494 self._Clone(revision, url, options) | |
| 495 else: | |
| 496 raise | |
| 466 | 497 |
| 467 if return_early: | 498 if return_early: |
| 468 return self._Capture(['rev-parse', '--verify', 'HEAD']) | 499 return self._Capture(['rev-parse', '--verify', 'HEAD']) |
| 469 | 500 |
| 470 cur_branch = self._GetCurrentBranch() | 501 cur_branch = self._GetCurrentBranch() |
| 471 | 502 |
| 472 # Cases: | 503 # Cases: |
| 473 # 0) HEAD is detached. Probably from our initial clone. | 504 # 0) HEAD is detached. Probably from our initial clone. |
| 474 # - make sure HEAD is contained by a named ref, then update. | 505 # - make sure HEAD is contained by a named ref, then update. |
| 475 # Cases 1-4. HEAD is a branch. | 506 # Cases 1-4. HEAD is a branch. |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1654 new_command.append('--force') | 1685 new_command.append('--force') |
| 1655 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1686 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1656 new_command.extend(('--accept', 'theirs-conflict')) | 1687 new_command.extend(('--accept', 'theirs-conflict')) |
| 1657 elif options.manually_grab_svn_rev: | 1688 elif options.manually_grab_svn_rev: |
| 1658 new_command.append('--force') | 1689 new_command.append('--force') |
| 1659 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1690 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1660 new_command.extend(('--accept', 'postpone')) | 1691 new_command.extend(('--accept', 'postpone')) |
| 1661 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1692 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1662 new_command.extend(('--accept', 'postpone')) | 1693 new_command.extend(('--accept', 'postpone')) |
| 1663 return new_command | 1694 return new_command |
| OLD | NEW |