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 import difflib | 10 import difflib |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 self.has_patchset = False | 676 self.has_patchset = False |
677 | 677 |
678 def GetMostRecentPatchset(self, issue): | 678 def GetMostRecentPatchset(self, issue): |
679 return self.RpcServer().get_issue_properties( | 679 return self.RpcServer().get_issue_properties( |
680 int(issue), False)['patchsets'][-1] | 680 int(issue), False)['patchsets'][-1] |
681 | 681 |
682 def GetPatchSetDiff(self, issue, patchset): | 682 def GetPatchSetDiff(self, issue, patchset): |
683 return self.RpcServer().get( | 683 return self.RpcServer().get( |
684 '/download/issue%s_%s.diff' % (issue, patchset)) | 684 '/download/issue%s_%s.diff' % (issue, patchset)) |
685 | 685 |
686 def GetApprovingReviewers(self, issue): | 686 def GetApprovingReviewers(self): |
687 return get_approving_reviewers( | 687 return get_approving_reviewers( |
688 self.RpcServer().get_issue_properties(int(issue), True)) | 688 self.RpcServer().get_issue_properties(self.GetIssue(), True)) |
689 | 689 |
690 def SetIssue(self, issue): | 690 def SetIssue(self, issue): |
691 """Set this branch's issue. If issue=0, clears the issue.""" | 691 """Set this branch's issue. If issue=0, clears the issue.""" |
692 if issue: | 692 if issue: |
693 RunGit(['config', self._IssueSetting(), str(issue)]) | 693 RunGit(['config', self._IssueSetting(), str(issue)]) |
694 if self.rietveld_server: | 694 if self.rietveld_server: |
695 RunGit(['config', self._RietveldServer(), self.rietveld_server]) | 695 RunGit(['config', self._RietveldServer(), self.rietveld_server]) |
696 else: | 696 else: |
697 RunGit(['config', '--unset', self._IssueSetting()]) | 697 RunGit(['config', '--unset', self._IssueSetting()]) |
698 self.SetPatchset(0) | 698 self.SetPatchset(0) |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 else: | 1570 else: |
1571 print 'No description set.' | 1571 print 'No description set.' |
1572 print 'Visit %s/edit to set it.' % (cl.GetIssueURL()) | 1572 print 'Visit %s/edit to set it.' % (cl.GetIssueURL()) |
1573 return 1 | 1573 return 1 |
1574 | 1574 |
1575 # Keep a separate copy for the commit message, because the commit message | 1575 # Keep a separate copy for the commit message, because the commit message |
1576 # contains the link to the Rietveld issue, while the Rietveld message contains | 1576 # contains the link to the Rietveld issue, while the Rietveld message contains |
1577 # the commit viewvc url. | 1577 # the commit viewvc url. |
1578 # Keep a separate copy for the commit message. | 1578 # Keep a separate copy for the commit message. |
1579 if cl.GetIssue(): | 1579 if cl.GetIssue(): |
1580 change_desc.update_reviewers(cl.GetApprovingReviewers(cl.GetIssue())) | 1580 change_desc.update_reviewers(cl.GetApprovingReviewers()) |
1581 | 1581 |
1582 commit_desc = ChangeDescription(change_desc.description) | 1582 commit_desc = ChangeDescription(change_desc.description) |
1583 if cl.GetIssue(): | 1583 if cl.GetIssue(): |
1584 commit_desc.append_footer('Review URL: %s' % cl.GetIssueURL()) | 1584 commit_desc.append_footer('Review URL: %s' % cl.GetIssueURL()) |
1585 if options.contributor: | 1585 if options.contributor: |
1586 commit_desc.append_footer('Patch from %s.' % options.contributor) | 1586 commit_desc.append_footer('Patch from %s.' % options.contributor) |
1587 | 1587 |
1588 print 'Description:', repr(commit_desc.description) | 1588 print 'Description:', repr(commit_desc.description) |
1589 | 1589 |
1590 branches = [base_branch, cl.GetBranchRef()] | 1590 branches = [base_branch, cl.GetBranchRef()] |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 GenUsage(parser, 'help') | 2177 GenUsage(parser, 'help') |
2178 return CMDhelp(parser, argv) | 2178 return CMDhelp(parser, argv) |
2179 | 2179 |
2180 | 2180 |
2181 if __name__ == '__main__': | 2181 if __name__ == '__main__': |
2182 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2182 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2183 # unit testing. | 2183 # unit testing. |
2184 fix_encoding.fix_encoding() | 2184 fix_encoding.fix_encoding() |
2185 colorama.init() | 2185 colorama.init() |
2186 sys.exit(main(sys.argv[1:])) | 2186 sys.exit(main(sys.argv[1:])) |
OLD | NEW |