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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 return remote, upstream_branch | 574 return remote, upstream_branch |
575 | 575 |
576 def GetCommonAncestorWithUpstream(self): | 576 def GetCommonAncestorWithUpstream(self): |
577 return git_common.get_or_create_merge_base(self.GetBranch(), | 577 return git_common.get_or_create_merge_base(self.GetBranch(), |
578 self.GetUpstreamBranch()) | 578 self.GetUpstreamBranch()) |
579 | 579 |
580 def GetUpstreamBranch(self): | 580 def GetUpstreamBranch(self): |
581 if self.upstream_branch is None: | 581 if self.upstream_branch is None: |
582 remote, upstream_branch = self.FetchUpstreamTuple(self.GetBranch()) | 582 remote, upstream_branch = self.FetchUpstreamTuple(self.GetBranch()) |
583 if remote is not '.': | 583 if remote is not '.': |
584 upstream_branch = upstream_branch.replace('heads', 'remotes/' + remote) | 584 upstream_branch = upstream_branch.replace('refs/heads/', |
| 585 'refs/remotes/%s/' % remote) |
| 586 upstream_branch = upstream_branch.replace('refs/branch-heads/', |
| 587 'refs/remotes/branch-heads/') |
585 self.upstream_branch = upstream_branch | 588 self.upstream_branch = upstream_branch |
586 return self.upstream_branch | 589 return self.upstream_branch |
587 | 590 |
588 def GetRemoteBranch(self): | 591 def GetRemoteBranch(self): |
589 if not self._remote: | 592 if not self._remote: |
590 remote, branch = None, self.GetBranch() | 593 remote, branch = None, self.GetBranch() |
591 seen_branches = set() | 594 seen_branches = set() |
592 while branch not in seen_branches: | 595 while branch not in seen_branches: |
593 seen_branches.add(branch) | 596 seen_branches.add(branch) |
594 remote, branch = self.FetchUpstreamTuple(branch) | 597 remote, branch = self.FetchUpstreamTuple(branch) |
(...skipping 13 matching lines...) Expand all Loading... |
608 self._remote, | 611 self._remote, |
609 GIT_INSTRUCTIONS_URL) | 612 GIT_INSTRUCTIONS_URL) |
610 else: | 613 else: |
611 logging.warn('Could not determine which remote this change is ' | 614 logging.warn('Could not determine which remote this change is ' |
612 'associated with. You may prevent this message by ' | 615 'associated with. You may prevent this message by ' |
613 'running "git svn info" as documented here: %s', | 616 'running "git svn info" as documented here: %s', |
614 GIT_INSTRUCTIONS_URL) | 617 GIT_INSTRUCTIONS_URL) |
615 branch = 'HEAD' | 618 branch = 'HEAD' |
616 if branch.startswith('refs/remotes'): | 619 if branch.startswith('refs/remotes'): |
617 self._remote = (remote, branch) | 620 self._remote = (remote, branch) |
| 621 elif branch.startswith('refs/branch-heads/'): |
| 622 self._remote = (remote, branch.replace('refs/', 'refs/remotes/')) |
618 else: | 623 else: |
619 self._remote = (remote, 'refs/remotes/%s/%s' % (remote, branch)) | 624 self._remote = (remote, 'refs/remotes/%s/%s' % (remote, branch)) |
620 return self._remote | 625 return self._remote |
621 | 626 |
622 def GitSanityChecks(self, upstream_git_obj): | 627 def GitSanityChecks(self, upstream_git_obj): |
623 """Checks git repo status and ensures diff is from local commits.""" | 628 """Checks git repo status and ensures diff is from local commits.""" |
624 | 629 |
625 # Verify the commit we're diffing against is in our current branch. | 630 # Verify the commit we're diffing against is in our current branch. |
626 upstream_sha = RunGit(['rev-parse', '--verify', upstream_git_obj]).strip() | 631 upstream_sha = RunGit(['rev-parse', '--verify', upstream_git_obj]).strip() |
627 common_ancestor = RunGit(['merge-base', upstream_sha, 'HEAD']).strip() | 632 common_ancestor = RunGit(['merge-base', upstream_sha, 'HEAD']).strip() |
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2742 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2738 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2743 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2739 | 2744 |
2740 | 2745 |
2741 if __name__ == '__main__': | 2746 if __name__ == '__main__': |
2742 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2747 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2743 # unit testing. | 2748 # unit testing. |
2744 fix_encoding.fix_encoding() | 2749 fix_encoding.fix_encoding() |
2745 colorama.init() | 2750 colorama.init() |
2746 sys.exit(main(sys.argv[1:])) | 2751 sys.exit(main(sys.argv[1:])) |
OLD | NEW |