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 and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
| 9 | 9 |
| 10 from __future__ import print_function | 10 from __future__ import print_function |
| (...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1730 return 'waiting' | 1730 return 'waiting' |
| 1731 | 1731 |
| 1732 def UpdateDescriptionRemote(self, description): | 1732 def UpdateDescriptionRemote(self, description): |
| 1733 return self.RpcServer().update_description( | 1733 return self.RpcServer().update_description( |
| 1734 self.GetIssue(), self.description) | 1734 self.GetIssue(), self.description) |
| 1735 | 1735 |
| 1736 def CloseIssue(self): | 1736 def CloseIssue(self): |
| 1737 return self.RpcServer().close_issue(self.GetIssue()) | 1737 return self.RpcServer().close_issue(self.GetIssue()) |
| 1738 | 1738 |
| 1739 def SetFlag(self, flag, value): | 1739 def SetFlag(self, flag, value): |
| 1740 return self.SetFlags({flag: value}) | |
| 1741 | |
| 1742 def SetFlags(self, flags): | |
| 1740 """Patchset must match.""" | 1743 """Patchset must match.""" |
|
Michael Achenbach
2016/07/06 07:47:59
fly-by nit: This is not a method comment, rather a
tandrii(chromium)
2016/07/06 10:44:03
Done.
| |
| 1741 if not self.GetPatchset(): | 1744 if not self.GetPatchset(): |
| 1742 DieWithError('The patchset needs to match. Send another patchset.') | 1745 DieWithError('The patchset needs to match. Send another patchset.') |
| 1743 try: | 1746 try: |
| 1744 return self.RpcServer().set_flag( | 1747 return self.RpcServer().set_flags( |
| 1745 self.GetIssue(), self.GetPatchset(), flag, value) | 1748 self.GetIssue(), self.GetPatchset(), flags) |
| 1746 except urllib2.HTTPError as e: | 1749 except urllib2.HTTPError as e: |
| 1747 if e.code == 404: | 1750 if e.code == 404: |
| 1748 DieWithError('The issue %s doesn\'t exist.' % self.GetIssue()) | 1751 DieWithError('The issue %s doesn\'t exist.' % self.GetIssue()) |
| 1749 if e.code == 403: | 1752 if e.code == 403: |
| 1750 DieWithError( | 1753 DieWithError( |
| 1751 ('Access denied to issue %s. Maybe the patchset %s doesn\'t ' | 1754 ('Access denied to issue %s. Maybe the patchset %s doesn\'t ' |
| 1752 'match?') % (self.GetIssue(), self.GetPatchset())) | 1755 'match?') % (self.GetIssue(), self.GetPatchset())) |
| 1753 raise | 1756 raise |
| 1754 | 1757 |
| 1755 def RpcServer(self): | 1758 def RpcServer(self): |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1781 return ['rietveldserver'] | 1784 return ['rietveldserver'] |
| 1782 | 1785 |
| 1783 def GetRieveldObjForPresubmit(self): | 1786 def GetRieveldObjForPresubmit(self): |
| 1784 return self.RpcServer() | 1787 return self.RpcServer() |
| 1785 | 1788 |
| 1786 def SetCQState(self, new_state): | 1789 def SetCQState(self, new_state): |
| 1787 props = self.GetIssueProperties() | 1790 props = self.GetIssueProperties() |
| 1788 if props.get('private'): | 1791 if props.get('private'): |
| 1789 DieWithError('Cannot set-commit on private issue') | 1792 DieWithError('Cannot set-commit on private issue') |
| 1790 | 1793 |
| 1791 if new_state == _CQState.COMMIT: | 1794 if new_state == _CQState.COMMIT: |
|
Michael Achenbach
2016/07/06 07:47:58
The dry_run flag also changes the commit flag, but
tandrii(chromium)
2016/07/06 10:44:03
well, this is rietveld API, and I'm not going to t
| |
| 1792 self.SetFlag('commit', '1') | 1795 self.SetFlag('commit', '1') |
| 1793 elif new_state == _CQState.NONE: | 1796 elif new_state == _CQState.NONE: |
| 1794 self.SetFlag('commit', '0') | 1797 self.SetFlag('commit', '0') |
| 1795 else: | 1798 else: |
| 1796 raise NotImplementedError() | 1799 assert new_state == _CQState.DRY_RUN |
| 1800 self.SetFlags({'commit': '1', 'cq_dry_run': '1'}) | |
| 1797 | 1801 |
| 1798 | 1802 |
| 1799 def CMDPatchWithParsedIssue(self, parsed_issue_arg, reject, nocommit, | 1803 def CMDPatchWithParsedIssue(self, parsed_issue_arg, reject, nocommit, |
| 1800 directory): | 1804 directory): |
| 1801 # TODO(maruel): Use apply_issue.py | 1805 # TODO(maruel): Use apply_issue.py |
| 1802 | 1806 |
| 1803 # PatchIssue should never be called with a dirty tree. It is up to the | 1807 # PatchIssue should never be called with a dirty tree. It is up to the |
| 1804 # caller to check this, but just in case we assert here since the | 1808 # caller to check this, but just in case we assert here since the |
| 1805 # consequences of the caller not checking this could be dire. | 1809 # consequences of the caller not checking this could be dire. |
| 1806 assert(not git_common.is_dirty_git_tree('apply')) | 1810 assert(not git_common.is_dirty_git_tree('apply')) |
| (...skipping 3290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5097 if __name__ == '__main__': | 5101 if __name__ == '__main__': |
| 5098 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5102 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 5099 # unit testing. | 5103 # unit testing. |
| 5100 fix_encoding.fix_encoding() | 5104 fix_encoding.fix_encoding() |
| 5101 setup_color.init() | 5105 setup_color.init() |
| 5102 try: | 5106 try: |
| 5103 sys.exit(main(sys.argv[1:])) | 5107 sys.exit(main(sys.argv[1:])) |
| 5104 except KeyboardInterrupt: | 5108 except KeyboardInterrupt: |
| 5105 sys.stderr.write('interrupted\n') | 5109 sys.stderr.write('interrupted\n') |
| 5106 sys.exit(1) | 5110 sys.exit(1) |
| OLD | NEW |