| OLD | NEW |
| 1 #!/usr/bin/python2 | 1 #!/usr/bin/python2 |
| 2 | 2 |
| 3 # Copyright 2014 Google Inc. | 3 # Copyright 2014 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 """Skia's Chromium DEPS roll script. | 8 """Skia's Chromium DEPS roll script. |
| 9 | 9 |
| 10 This script: | 10 This script: |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 """Return true iff branch exists.""" | 570 """Return true iff branch exists.""" |
| 571 return 0 == vsp.call([git, 'show-ref', '--quiet', branch]) | 571 return 0 == vsp.call([git, 'show-ref', '--quiet', branch]) |
| 572 def has_diff(): | 572 def has_diff(): |
| 573 """Return true iff repository has uncommited changes.""" | 573 """Return true iff repository has uncommited changes.""" |
| 574 return bool(vsp.call([git, 'diff', '--quiet', 'HEAD'])) | 574 return bool(vsp.call([git, 'diff', '--quiet', 'HEAD'])) |
| 575 | 575 |
| 576 self._stash = has_diff() | 576 self._stash = has_diff() |
| 577 if self._stash: | 577 if self._stash: |
| 578 vsp.check_call([git, 'stash', 'save']) | 578 vsp.check_call([git, 'stash', 'save']) |
| 579 try: | 579 try: |
| 580 self._original_branch = vsp.strip_output( | 580 full_branch = vsp.strip_output([git, 'symbolic-ref', 'HEAD']) |
| 581 [git, 'symbolic-ref', '--short', 'HEAD']) | 581 self._original_branch = full_branch.split('/')[-1] |
| 582 except (subprocess.CalledProcessError,): | 582 except (subprocess.CalledProcessError,): |
| 583 self._original_branch = vsp.strip_output( | 583 self._original_branch = vsp.strip_output( |
| 584 [git, 'rev-parse', 'HEAD']) | 584 [git, 'rev-parse', 'HEAD']) |
| 585 | 585 |
| 586 if not self._branch_name: | 586 if not self._branch_name: |
| 587 self._branch_name = self._config.default_branch_name | 587 self._branch_name = self._config.default_branch_name |
| 588 | 588 |
| 589 if branch_exists(self._branch_name): | 589 if branch_exists(self._branch_name): |
| 590 vsp.check_call([git, 'checkout', '-q', 'master']) | 590 vsp.check_call([git, 'checkout', '-q', 'master']) |
| 591 vsp.check_call([git, 'branch', '-q', '-D', self._branch_name]) | 591 vsp.check_call([git, 'branch', '-D', self._branch_name]) |
| 592 | 592 |
| 593 vsp.check_call( | 593 vsp.check_call( |
| 594 [git, 'checkout', '-q', '-b', self._branch_name, 'origin/master']) | 594 [git, 'checkout', '-q', '-b', self._branch_name, 'origin/master']) |
| 595 | 595 |
| 596 def __exit__(self, etype, value, traceback): | 596 def __exit__(self, etype, value, traceback): |
| 597 # pylint: disable=I0011,R0912 | 597 # pylint: disable=I0011,R0912 |
| 598 git = self._config.git | 598 git = self._config.git |
| 599 vsp = self._config.vsp | 599 vsp = self._config.vsp |
| 600 svn_info = str(get_svn_revision(self._config, 'HEAD')) | 600 svn_info = str(get_svn_revision(self._config, 'HEAD')) |
| 601 | 601 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 625 self.issue = vsp.strip_output([git, 'cl', 'issue']) | 625 self.issue = vsp.strip_output([git, 'cl', 'issue']) |
| 626 if self._config.cl_bot_list: | 626 if self._config.cl_bot_list: |
| 627 vsp.check_call(git_try) | 627 vsp.check_call(git_try) |
| 628 | 628 |
| 629 # deal with the aftermath of failed executions of this script. | 629 # deal with the aftermath of failed executions of this script. |
| 630 if self._config.default_branch_name == self._original_branch: | 630 if self._config.default_branch_name == self._original_branch: |
| 631 self._original_branch = 'master' | 631 self._original_branch = 'master' |
| 632 vsp.check_call([git, 'checkout', '-q', self._original_branch]) | 632 vsp.check_call([git, 'checkout', '-q', self._original_branch]) |
| 633 | 633 |
| 634 if self._config.default_branch_name == self._branch_name: | 634 if self._config.default_branch_name == self._branch_name: |
| 635 vsp.check_call([git, 'branch', '-q', '-D', self._branch_name]) | 635 vsp.check_call([git, 'branch', '-D', self._branch_name]) |
| 636 if self._stash: | 636 if self._stash: |
| 637 vsp.check_call([git, 'stash', 'pop']) | 637 vsp.check_call([git, 'stash', 'pop']) |
| 638 | 638 |
| 639 | 639 |
| 640 def change_skia_deps(revision, git_hash, depspath): | 640 def change_skia_deps(revision, git_hash, depspath): |
| 641 """Update the DEPS file. | 641 """Update the DEPS file. |
| 642 | 642 |
| 643 Modify the skia_revision and skia_hash entries in the given DEPS file. | 643 Modify the skia_revision and skia_hash entries in the given DEPS file. |
| 644 | 644 |
| 645 Args: | 645 Args: |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 if not test_git_executable(options.git_path): | 801 if not test_git_executable(options.git_path): |
| 802 option_parser.error('Invalid git executable.') | 802 option_parser.error('Invalid git executable.') |
| 803 | 803 |
| 804 config = DepsRollConfig(options) | 804 config = DepsRollConfig(options) |
| 805 find_hash_and_roll_deps(config, options.revision, options.git_hash) | 805 find_hash_and_roll_deps(config, options.revision, options.git_hash) |
| 806 | 806 |
| 807 | 807 |
| 808 if __name__ == '__main__': | 808 if __name__ == '__main__': |
| 809 main(sys.argv[1:]) | 809 main(sys.argv[1:]) |
| 810 | 810 |
| OLD | NEW |