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 3260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3271 - Green LGTM'ed | 3271 - Green LGTM'ed |
3272 - Magenta in the commit queue | 3272 - Magenta in the commit queue |
3273 - Cyan was committed, branch can be deleted | 3273 - Cyan was committed, branch can be deleted |
3274 | 3274 |
3275 Also see 'git cl comments'. | 3275 Also see 'git cl comments'. |
3276 """ | 3276 """ |
3277 parser.add_option('--field', | 3277 parser.add_option('--field', |
3278 help='print only specific field (desc|id|patch|status|url)') | 3278 help='print only specific field (desc|id|patch|status|url)') |
3279 parser.add_option('-f', '--fast', action='store_true', | 3279 parser.add_option('-f', '--fast', action='store_true', |
3280 help='Do not retrieve review status') | 3280 help='Do not retrieve review status') |
| 3281 parser.add_option('-i', '--issue', type=int, |
| 3282 help='Operate on this issue number instead of the current' |
| 3283 ' branch\'s implicit issue. Only valid with --field.') |
3281 parser.add_option( | 3284 parser.add_option( |
3282 '-j', '--maxjobs', action='store', type=int, | 3285 '-j', '--maxjobs', action='store', type=int, |
3283 help='The maximum number of jobs to use when retrieving review status') | 3286 help='The maximum number of jobs to use when retrieving review status') |
3284 | 3287 |
3285 auth.add_auth_options(parser) | 3288 auth.add_auth_options(parser) |
| 3289 _add_codereview_select_options(parser) |
3286 options, args = parser.parse_args(args) | 3290 options, args = parser.parse_args(args) |
| 3291 _process_codereview_select_options(parser, options) |
3287 if args: | 3292 if args: |
3288 parser.error('Unsupported args: %s' % args) | 3293 parser.error('Unsupported args: %s' % args) |
3289 auth_config = auth.extract_auth_config_from_options(options) | 3294 auth_config = auth.extract_auth_config_from_options(options) |
3290 | 3295 |
| 3296 if options.issue is not None: |
| 3297 if not options.field or not options.forced_codereview: |
| 3298 parser.error('--issue may only be specified in conjunction with --field' |
| 3299 ' and either --rietveld or --gerrit') |
| 3300 |
3291 if options.field: | 3301 if options.field: |
3292 cl = Changelist(auth_config=auth_config) | 3302 cl = Changelist(auth_config=auth_config, issue=options.issue, |
| 3303 codereview=options.forced_codereview) |
3293 if options.field.startswith('desc'): | 3304 if options.field.startswith('desc'): |
3294 print(cl.GetDescription()) | 3305 print(cl.GetDescription()) |
3295 elif options.field == 'id': | 3306 elif options.field == 'id': |
3296 issueid = cl.GetIssue() | 3307 issueid = cl.GetIssue() |
3297 if issueid: | 3308 if issueid: |
3298 print(issueid) | 3309 print(issueid) |
3299 elif options.field == 'patch': | 3310 elif options.field == 'patch': |
3300 patchset = cl.GetPatchset() | 3311 patchset = cl.GetPatchset() |
3301 if patchset: | 3312 if patchset: |
3302 print(patchset) | 3313 print(patchset) |
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5109 if __name__ == '__main__': | 5120 if __name__ == '__main__': |
5110 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5121 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5111 # unit testing. | 5122 # unit testing. |
5112 fix_encoding.fix_encoding() | 5123 fix_encoding.fix_encoding() |
5113 setup_color.init() | 5124 setup_color.init() |
5114 try: | 5125 try: |
5115 sys.exit(main(sys.argv[1:])) | 5126 sys.exit(main(sys.argv[1:])) |
5116 except KeyboardInterrupt: | 5127 except KeyboardInterrupt: |
5117 sys.stderr.write('interrupted\n') | 5128 sys.stderr.write('interrupted\n') |
5118 sys.exit(1) | 5129 sys.exit(1) |
OLD | NEW |