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 distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 4532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4543 parser.print_help() | 4543 parser.print_help() |
4544 return 1 | 4544 return 1 |
4545 | 4545 |
4546 issue_arg = ParseIssueNumberArgument(args[0]) | 4546 issue_arg = ParseIssueNumberArgument(args[0]) |
4547 if not issue_arg.valid: | 4547 if not issue_arg.valid: |
4548 parser.print_help() | 4548 parser.print_help() |
4549 return 1 | 4549 return 1 |
4550 target_issue = str(issue_arg.issue) | 4550 target_issue = str(issue_arg.issue) |
4551 | 4551 |
4552 def find_issues(issueprefix): | 4552 def find_issues(issueprefix): |
4553 key_and_issues = [x.split() for x in RunGit( | 4553 output = RunGit(['config', '--local', '--get-regexp', |
4554 ['config', '--local', '--get-regexp', r'branch\..*\.%s' % issueprefix]) | 4554 r'branch\..*\.%s' % issueprefix], |
4555 .splitlines()] | 4555 error_ok=True) |
4556 for key, issue in key_and_issues: | 4556 for key, issue in [x.split() for x in output.splitlines()]: |
4557 if issue == target_issue: | 4557 if issue == target_issue: |
4558 yield re.sub(r'branch\.(.*)\.%s' % issueprefix, r'\1', key) | 4558 yield re.sub(r'branch\.(.*)\.%s' % issueprefix, r'\1', key) |
4559 | 4559 |
4560 branches = [] | 4560 branches = [] |
4561 for cls in _CODEREVIEW_IMPLEMENTATIONS.values(): | 4561 for cls in _CODEREVIEW_IMPLEMENTATIONS.values(): |
4562 branches.extend(find_issues(cls.IssueSettingPrefix())) | 4562 branches.extend(find_issues(cls.IssueSettingPrefix())) |
4563 if len(branches) == 0: | 4563 if len(branches) == 0: |
4564 print 'No branch found for issue %s.' % target_issue | 4564 print 'No branch found for issue %s.' % target_issue |
4565 return 1 | 4565 return 1 |
4566 if len(branches) == 1: | 4566 if len(branches) == 1: |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4634 if __name__ == '__main__': | 4634 if __name__ == '__main__': |
4635 # These affect sys.stdout so do it outside of main() to simplify mocks in | 4635 # These affect sys.stdout so do it outside of main() to simplify mocks in |
4636 # unit testing. | 4636 # unit testing. |
4637 fix_encoding.fix_encoding() | 4637 fix_encoding.fix_encoding() |
4638 setup_color.init() | 4638 setup_color.init() |
4639 try: | 4639 try: |
4640 sys.exit(main(sys.argv[1:])) | 4640 sys.exit(main(sys.argv[1:])) |
4641 except KeyboardInterrupt: | 4641 except KeyboardInterrupt: |
4642 sys.stderr.write('interrupted\n') | 4642 sys.stderr.write('interrupted\n') |
4643 sys.exit(1) | 4643 sys.exit(1) |
OLD | NEW |