Chromium Code Reviews| 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 | 518 |
| 519 def SetWatchers(self, watchers): | 519 def SetWatchers(self, watchers): |
| 520 """Set the list of email addresses that should be cc'd based on the changed | 520 """Set the list of email addresses that should be cc'd based on the changed |
| 521 files in this CL. | 521 files in this CL. |
| 522 """ | 522 """ |
| 523 self.watchers = watchers | 523 self.watchers = watchers |
| 524 | 524 |
| 525 def GetBranch(self): | 525 def GetBranch(self): |
| 526 """Returns the short branch name, e.g. 'master'.""" | 526 """Returns the short branch name, e.g. 'master'.""" |
| 527 if not self.branch: | 527 if not self.branch: |
| 528 self.branchref = RunGit(['symbolic-ref', 'HEAD']).strip() | 528 branchref = RunGit(['symbolic-ref', 'HEAD'], |
| 529 stderr=subprocess2.VOID, error_ok=True).strip() | |
| 530 if not branchref: | |
| 531 return None | |
| 532 self.branchref = branchref | |
|
pgervais
2014/10/20 20:45:57
Please define self.branchref in __init__.
szager1
2014/10/20 22:29:52
It already is.
| |
| 529 self.branch = ShortBranchName(self.branchref) | 533 self.branch = ShortBranchName(self.branchref) |
| 530 return self.branch | 534 return self.branch |
| 531 | 535 |
| 532 def GetBranchRef(self): | 536 def GetBranchRef(self): |
| 533 """Returns the full branch name, e.g. 'refs/heads/master'.""" | 537 """Returns the full branch name, e.g. 'refs/heads/master'.""" |
| 534 self.GetBranch() # Poke the lazy loader. | 538 self.GetBranch() # Poke the lazy loader. |
| 535 return self.branchref | 539 return self.branchref |
| 536 | 540 |
| 537 @staticmethod | 541 @staticmethod |
| 538 def FetchUpstreamTuple(branch): | 542 def FetchUpstreamTuple(branch): |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 issue = RunGit(['config', self._IssueSetting()], error_ok=True).strip() | 693 issue = RunGit(['config', self._IssueSetting()], error_ok=True).strip() |
| 690 self.issue = int(issue) or None if issue else None | 694 self.issue = int(issue) or None if issue else None |
| 691 self.lookedup_issue = True | 695 self.lookedup_issue = True |
| 692 return self.issue | 696 return self.issue |
| 693 | 697 |
| 694 def GetRietveldServer(self): | 698 def GetRietveldServer(self): |
| 695 if not self.rietveld_server: | 699 if not self.rietveld_server: |
| 696 # If we're on a branch then get the server potentially associated | 700 # If we're on a branch then get the server potentially associated |
| 697 # with that branch. | 701 # with that branch. |
| 698 if self.GetIssue(): | 702 if self.GetIssue(): |
| 699 self.rietveld_server = gclient_utils.UpgradeToHttps(RunGit( | 703 rietveld_server_config = self._RietveldServer() |
| 700 ['config', self._RietveldServer()], error_ok=True).strip()) | 704 if rietveld_server_config: |
| 705 self.rietveld_server = gclient_utils.UpgradeToHttps(RunGit( | |
| 706 ['config', rietveld_server_config], error_ok=True).strip()) | |
| 701 if not self.rietveld_server: | 707 if not self.rietveld_server: |
| 702 self.rietveld_server = settings.GetDefaultServerUrl() | 708 self.rietveld_server = settings.GetDefaultServerUrl() |
| 703 return self.rietveld_server | 709 return self.rietveld_server |
| 704 | 710 |
| 705 def GetIssueURL(self): | 711 def GetIssueURL(self): |
| 706 """Get the URL for a particular issue.""" | 712 """Get the URL for a particular issue.""" |
| 707 if not self.GetIssue(): | 713 if not self.GetIssue(): |
| 708 return None | 714 return None |
| 709 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) | 715 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) |
| 710 | 716 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 935 def _IssueSetting(self): | 941 def _IssueSetting(self): |
| 936 """Return the git setting that stores this change's issue.""" | 942 """Return the git setting that stores this change's issue.""" |
| 937 return 'branch.%s.rietveldissue' % self.GetBranch() | 943 return 'branch.%s.rietveldissue' % self.GetBranch() |
| 938 | 944 |
| 939 def _PatchsetSetting(self): | 945 def _PatchsetSetting(self): |
| 940 """Return the git setting that stores this change's most recent patchset.""" | 946 """Return the git setting that stores this change's most recent patchset.""" |
| 941 return 'branch.%s.rietveldpatchset' % self.GetBranch() | 947 return 'branch.%s.rietveldpatchset' % self.GetBranch() |
| 942 | 948 |
| 943 def _RietveldServer(self): | 949 def _RietveldServer(self): |
| 944 """Returns the git setting that stores this change's rietveld server.""" | 950 """Returns the git setting that stores this change's rietveld server.""" |
| 945 return 'branch.%s.rietveldserver' % self.GetBranch() | 951 branch = self.GetBranch() |
| 952 if branch: | |
| 953 return 'branch.%s.rietveldserver' % branch | |
| 954 return None | |
| 946 | 955 |
| 947 | 956 |
| 948 def GetCodereviewSettingsInteractively(): | 957 def GetCodereviewSettingsInteractively(): |
| 949 """Prompt the user for settings.""" | 958 """Prompt the user for settings.""" |
| 950 # TODO(ukai): ask code review system is rietveld or gerrit? | 959 # TODO(ukai): ask code review system is rietveld or gerrit? |
| 951 server = settings.GetDefaultServerUrl(error_ok=True) | 960 server = settings.GetDefaultServerUrl(error_ok=True) |
| 952 prompt = 'Rietveld server (host[:port])' | 961 prompt = 'Rietveld server (host[:port])' |
| 953 prompt += ' [%s]' % (server or DEFAULT_SERVER) | 962 prompt += ' [%s]' % (server or DEFAULT_SERVER) |
| 954 newserver = ask_for_data(prompt + ':') | 963 newserver = ask_for_data(prompt + ':') |
| 955 if not server and not newserver: | 964 if not server and not newserver: |
| (...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2874 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2883 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2875 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2884 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2876 | 2885 |
| 2877 | 2886 |
| 2878 if __name__ == '__main__': | 2887 if __name__ == '__main__': |
| 2879 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2888 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2880 # unit testing. | 2889 # unit testing. |
| 2881 fix_encoding.fix_encoding() | 2890 fix_encoding.fix_encoding() |
| 2882 colorama.init() | 2891 colorama.init() |
| 2883 sys.exit(main(sys.argv[1:])) | 2892 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |