| 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 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 | 1588 |
| 1589 Issue must have been already uploaded and known. | 1589 Issue must have been already uploaded and known. |
| 1590 """ | 1590 """ |
| 1591 raise NotImplementedError() | 1591 raise NotImplementedError() |
| 1592 | 1592 |
| 1593 | 1593 |
| 1594 class _RietveldChangelistImpl(_ChangelistCodereviewBase): | 1594 class _RietveldChangelistImpl(_ChangelistCodereviewBase): |
| 1595 def __init__(self, changelist, auth_config=None, rietveld_server=None): | 1595 def __init__(self, changelist, auth_config=None, rietveld_server=None): |
| 1596 super(_RietveldChangelistImpl, self).__init__(changelist) | 1596 super(_RietveldChangelistImpl, self).__init__(changelist) |
| 1597 assert settings, 'must be initialized in _ChangelistCodereviewBase' | 1597 assert settings, 'must be initialized in _ChangelistCodereviewBase' |
| 1598 settings.GetDefaultServerUrl() | 1598 if not rietveld_server: |
| 1599 settings.GetDefaultServerUrl() |
| 1599 | 1600 |
| 1600 self._rietveld_server = rietveld_server | 1601 self._rietveld_server = rietveld_server |
| 1601 self._auth_config = auth_config | 1602 self._auth_config = auth_config |
| 1602 self._props = None | 1603 self._props = None |
| 1603 self._rpc_server = None | 1604 self._rpc_server = None |
| 1604 | 1605 |
| 1605 def GetCodereviewServer(self): | 1606 def GetCodereviewServer(self): |
| 1606 if not self._rietveld_server: | 1607 if not self._rietveld_server: |
| 1607 # If we're on a branch then get the server potentially associated | 1608 # If we're on a branch then get the server potentially associated |
| 1608 # with that branch. | 1609 # with that branch. |
| (...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3472 parser.add_option('-n', '--new-description', | 3473 parser.add_option('-n', '--new-description', |
| 3473 help='New description to set for this issue (- for stdin)') | 3474 help='New description to set for this issue (- for stdin)') |
| 3474 | 3475 |
| 3475 _add_codereview_select_options(parser) | 3476 _add_codereview_select_options(parser) |
| 3476 auth.add_auth_options(parser) | 3477 auth.add_auth_options(parser) |
| 3477 options, args = parser.parse_args(args) | 3478 options, args = parser.parse_args(args) |
| 3478 _process_codereview_select_options(parser, options) | 3479 _process_codereview_select_options(parser, options) |
| 3479 | 3480 |
| 3480 target_issue = None | 3481 target_issue = None |
| 3481 if len(args) > 0: | 3482 if len(args) > 0: |
| 3482 issue_arg = ParseIssueNumberArgument(args[0]) | 3483 target_issue = ParseIssueNumberArgument(args[0]) |
| 3483 if not issue_arg.valid: | 3484 if not target_issue.valid: |
| 3484 parser.print_help() | 3485 parser.print_help() |
| 3485 return 1 | 3486 return 1 |
| 3486 target_issue = issue_arg.issue | |
| 3487 | 3487 |
| 3488 auth_config = auth.extract_auth_config_from_options(options) | 3488 auth_config = auth.extract_auth_config_from_options(options) |
| 3489 | 3489 |
| 3490 cl = Changelist( | 3490 kwargs = { |
| 3491 auth_config=auth_config, issue=target_issue, | 3491 'auth_config': auth_config, |
| 3492 codereview=options.forced_codereview) | 3492 'codereview': options.forced_codereview, |
| 3493 } |
| 3494 if target_issue: |
| 3495 kwargs['issue'] = target_issue.issue |
| 3496 if options.forced_codereview == 'rietveld': |
| 3497 kwargs['rietveld_server'] = target_issue.hostname |
| 3498 |
| 3499 cl = Changelist(**kwargs) |
| 3493 | 3500 |
| 3494 if not cl.GetIssue(): | 3501 if not cl.GetIssue(): |
| 3495 DieWithError('This branch has no associated changelist.') | 3502 DieWithError('This branch has no associated changelist.') |
| 3496 description = ChangeDescription(cl.GetDescription()) | 3503 description = ChangeDescription(cl.GetDescription()) |
| 3497 | 3504 |
| 3498 if options.display: | 3505 if options.display: |
| 3499 print(description.description) | 3506 print(description.description) |
| 3500 return 0 | 3507 return 0 |
| 3501 | 3508 |
| 3502 if options.new_description: | 3509 if options.new_description: |
| (...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5078 if __name__ == '__main__': | 5085 if __name__ == '__main__': |
| 5079 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5086 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 5080 # unit testing. | 5087 # unit testing. |
| 5081 fix_encoding.fix_encoding() | 5088 fix_encoding.fix_encoding() |
| 5082 setup_color.init() | 5089 setup_color.init() |
| 5083 try: | 5090 try: |
| 5084 sys.exit(main(sys.argv[1:])) | 5091 sys.exit(main(sys.argv[1:])) |
| 5085 except KeyboardInterrupt: | 5092 except KeyboardInterrupt: |
| 5086 sys.stderr.write('interrupted\n') | 5093 sys.stderr.write('interrupted\n') |
| 5087 sys.exit(1) | 5094 sys.exit(1) |
| OLD | NEW |