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 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 self.GetIssue(), self.description) | 1724 self.GetIssue(), self.description) |
1725 | 1725 |
1726 def CloseIssue(self): | 1726 def CloseIssue(self): |
1727 return self.RpcServer().close_issue(self.GetIssue()) | 1727 return self.RpcServer().close_issue(self.GetIssue()) |
1728 | 1728 |
1729 def SetFlag(self, flag, value): | 1729 def SetFlag(self, flag, value): |
1730 return self.SetFlags({flag: value}) | 1730 return self.SetFlags({flag: value}) |
1731 | 1731 |
1732 def SetFlags(self, flags): | 1732 def SetFlags(self, flags): |
1733 """Sets flags on this CL/patchset in Rietveld. | 1733 """Sets flags on this CL/patchset in Rietveld. |
1734 | |
1735 The latest patchset in Rietveld must be the same as latest known locally. | |
1736 """ | 1734 """ |
1737 if not self.GetPatchset(): | 1735 patchset = self.GetPatchset() or self.GetMostRecentPatchset() |
1738 DieWithError('The patchset needs to match. Send another patchset.') | |
1739 try: | 1736 try: |
1740 return self.RpcServer().set_flags( | 1737 return self.RpcServer().set_flags( |
1741 self.GetIssue(), self.GetPatchset(), flags) | 1738 self.GetIssue(), patchset, flags) |
1742 except urllib2.HTTPError as e: | 1739 except urllib2.HTTPError as e: |
1743 if e.code == 404: | 1740 if e.code == 404: |
1744 DieWithError('The issue %s doesn\'t exist.' % self.GetIssue()) | 1741 DieWithError('The issue %s doesn\'t exist.' % self.GetIssue()) |
1745 if e.code == 403: | 1742 if e.code == 403: |
1746 DieWithError( | 1743 DieWithError( |
1747 ('Access denied to issue %s. Maybe the patchset %s doesn\'t ' | 1744 ('Access denied to issue %s. Maybe the patchset %s doesn\'t ' |
1748 'match?') % (self.GetIssue(), self.GetPatchset())) | 1745 'match?') % (self.GetIssue(), patchset)) |
1749 raise | 1746 raise |
1750 | 1747 |
1751 def RpcServer(self): | 1748 def RpcServer(self): |
1752 """Returns an upload.RpcServer() to access this review's rietveld instance. | 1749 """Returns an upload.RpcServer() to access this review's rietveld instance. |
1753 """ | 1750 """ |
1754 if not self._rpc_server: | 1751 if not self._rpc_server: |
1755 self._rpc_server = rietveld.CachingRietveld( | 1752 self._rpc_server = rietveld.CachingRietveld( |
1756 self.GetCodereviewServer(), | 1753 self.GetCodereviewServer(), |
1757 self._auth_config or auth.make_auth_config()) | 1754 self._auth_config or auth.make_auth_config()) |
1758 return self._rpc_server | 1755 return self._rpc_server |
(...skipping 2959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4718 return 0 | 4715 return 0 |
4719 | 4716 |
4720 | 4717 |
4721 def CMDset_commit(parser, args): | 4718 def CMDset_commit(parser, args): |
4722 """Sets the commit bit to trigger the Commit Queue.""" | 4719 """Sets the commit bit to trigger the Commit Queue.""" |
4723 parser.add_option('-d', '--dry-run', action='store_true', | 4720 parser.add_option('-d', '--dry-run', action='store_true', |
4724 help='trigger in dry run mode') | 4721 help='trigger in dry run mode') |
4725 parser.add_option('-c', '--clear', action='store_true', | 4722 parser.add_option('-c', '--clear', action='store_true', |
4726 help='stop CQ run, if any') | 4723 help='stop CQ run, if any') |
4727 auth.add_auth_options(parser) | 4724 auth.add_auth_options(parser) |
| 4725 _add_codereview_select_options(parser) |
4728 options, args = parser.parse_args(args) | 4726 options, args = parser.parse_args(args) |
| 4727 _process_codereview_select_options(parser, options) |
4729 auth_config = auth.extract_auth_config_from_options(options) | 4728 auth_config = auth.extract_auth_config_from_options(options) |
4730 if args: | 4729 if args: |
4731 parser.error('Unrecognized args: %s' % ' '.join(args)) | 4730 parser.error('Unrecognized args: %s' % ' '.join(args)) |
4732 if options.dry_run and options.clear: | 4731 if options.dry_run and options.clear: |
4733 parser.error('Make up your mind: both --dry-run and --clear not allowed') | 4732 parser.error('Make up your mind: both --dry-run and --clear not allowed') |
4734 | 4733 |
4735 cl = Changelist(auth_config=auth_config) | 4734 cl = Changelist(auth_config=auth_config) |
4736 if options.clear: | 4735 if options.clear: |
4737 state = _CQState.NONE | 4736 state = _CQState.NONE |
4738 elif options.dry_run: | 4737 elif options.dry_run: |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5104 if __name__ == '__main__': | 5103 if __name__ == '__main__': |
5105 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5104 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5106 # unit testing. | 5105 # unit testing. |
5107 fix_encoding.fix_encoding() | 5106 fix_encoding.fix_encoding() |
5108 setup_color.init() | 5107 setup_color.init() |
5109 try: | 5108 try: |
5110 sys.exit(main(sys.argv[1:])) | 5109 sys.exit(main(sys.argv[1:])) |
5111 except KeyboardInterrupt: | 5110 except KeyboardInterrupt: |
5112 sys.stderr.write('interrupted\n') | 5111 sys.stderr.write('interrupted\n') |
5113 sys.exit(1) | 5112 sys.exit(1) |
OLD | NEW |