| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 self._remote = (remote, branch) | 634 self._remote = (remote, branch) |
| 635 elif branch.startswith('refs/branch-heads/'): | 635 elif branch.startswith('refs/branch-heads/'): |
| 636 self._remote = (remote, branch.replace('refs/', 'refs/remotes/')) | 636 self._remote = (remote, branch.replace('refs/', 'refs/remotes/')) |
| 637 else: | 637 else: |
| 638 self._remote = (remote, 'refs/remotes/%s/%s' % (remote, branch)) | 638 self._remote = (remote, 'refs/remotes/%s/%s' % (remote, branch)) |
| 639 return self._remote | 639 return self._remote |
| 640 | 640 |
| 641 def GitSanityChecks(self, upstream_git_obj): | 641 def GitSanityChecks(self, upstream_git_obj): |
| 642 """Checks git repo status and ensures diff is from local commits.""" | 642 """Checks git repo status and ensures diff is from local commits.""" |
| 643 | 643 |
| 644 if upstream_git_obj is None: |
| 645 if self.GetBranch() is None: |
| 646 print >> sys.stderr, ( |
| 647 'ERROR: unable to dertermine current branch (detached HEAD?)') |
| 648 else: |
| 649 print >> sys.stderr, ( |
| 650 'ERROR: no upstream branch') |
| 651 return False |
| 652 |
| 644 # Verify the commit we're diffing against is in our current branch. | 653 # Verify the commit we're diffing against is in our current branch. |
| 645 upstream_sha = RunGit(['rev-parse', '--verify', upstream_git_obj]).strip() | 654 upstream_sha = RunGit(['rev-parse', '--verify', upstream_git_obj]).strip() |
| 646 common_ancestor = RunGit(['merge-base', upstream_sha, 'HEAD']).strip() | 655 common_ancestor = RunGit(['merge-base', upstream_sha, 'HEAD']).strip() |
| 647 if upstream_sha != common_ancestor: | 656 if upstream_sha != common_ancestor: |
| 648 print >> sys.stderr, ( | 657 print >> sys.stderr, ( |
| 649 'ERROR: %s is not in the current branch. You may need to rebase ' | 658 'ERROR: %s is not in the current branch. You may need to rebase ' |
| 650 'your tracking branch' % upstream_sha) | 659 'your tracking branch' % upstream_sha) |
| 651 return False | 660 return False |
| 652 | 661 |
| 653 # List the commits inside the diff, and verify they are all local. | 662 # List the commits inside the diff, and verify they are all local. |
| (...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2916 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2925 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2917 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2926 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2918 | 2927 |
| 2919 | 2928 |
| 2920 if __name__ == '__main__': | 2929 if __name__ == '__main__': |
| 2921 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2930 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2922 # unit testing. | 2931 # unit testing. |
| 2923 fix_encoding.fix_encoding() | 2932 fix_encoding.fix_encoding() |
| 2924 colorama.init() | 2933 colorama.init() |
| 2925 sys.exit(main(sys.argv[1:])) | 2934 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |