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 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 # Extra options that can be specified at push time. Doc: | 2461 # Extra options that can be specified at push time. Doc: |
2462 # https://gerrit-review.googlesource.com/Documentation/user-upload.html | 2462 # https://gerrit-review.googlesource.com/Documentation/user-upload.html |
2463 refspec_opts = [] | 2463 refspec_opts = [] |
2464 if options.title: | 2464 if options.title: |
2465 # Per doc, spaces must be converted to underscores, and Gerrit will do the | 2465 # Per doc, spaces must be converted to underscores, and Gerrit will do the |
2466 # reverse on its side. | 2466 # reverse on its side. |
2467 if '_' in options.title: | 2467 if '_' in options.title: |
2468 print('WARNING: underscores in title will be converted to spaces.') | 2468 print('WARNING: underscores in title will be converted to spaces.') |
2469 refspec_opts.append('m=' + options.title.replace(' ', '_')) | 2469 refspec_opts.append('m=' + options.title.replace(' ', '_')) |
2470 | 2470 |
| 2471 if options.send_mail: |
| 2472 if not change_desc.get_reviewers(): |
| 2473 DieWithError('Must specify reviewers to send email.') |
| 2474 refspec_opts.append('notify=ALL') |
| 2475 else: |
| 2476 refspec_opts.append('notify=NONE') |
| 2477 |
2471 cc = self.GetCCList().split(',') | 2478 cc = self.GetCCList().split(',') |
2472 if options.cc: | 2479 if options.cc: |
2473 cc.extend(options.cc) | 2480 cc.extend(options.cc) |
2474 cc = filter(None, cc) | 2481 cc = filter(None, cc) |
2475 if cc: | 2482 if cc: |
2476 # refspec_opts.extend('cc=' + email.strip() for email in cc) | 2483 # refspec_opts.extend('cc=' + email.strip() for email in cc) |
2477 # TODO(tandrii): enable this back. http://crbug.com/604377 | 2484 # TODO(tandrii): enable this back. http://crbug.com/604377 |
2478 print('WARNING: Gerrit doesn\'t yet support cc-ing arbitrary emails.\n' | 2485 print('WARNING: Gerrit doesn\'t yet support cc-ing arbitrary emails.\n' |
2479 ' Ignoring cc-ed emails. See http://crbug.com/604377.') | 2486 ' Ignoring cc-ed emails. See http://crbug.com/604377.') |
2480 | 2487 |
2481 if change_desc.get_reviewers(): | 2488 if change_desc.get_reviewers(): |
2482 refspec_opts.extend('r=' + email.strip() | 2489 refspec_opts.extend('r=' + email.strip() |
2483 for email in change_desc.get_reviewers()) | 2490 for email in change_desc.get_reviewers()) |
2484 | 2491 |
2485 | |
2486 refspec_suffix = '' | 2492 refspec_suffix = '' |
2487 if refspec_opts: | 2493 if refspec_opts: |
2488 refspec_suffix = '%' + ','.join(refspec_opts) | 2494 refspec_suffix = '%' + ','.join(refspec_opts) |
2489 assert ' ' not in refspec_suffix, ( | 2495 assert ' ' not in refspec_suffix, ( |
2490 'spaces not allowed in refspec: "%s"' % refspec_suffix) | 2496 'spaces not allowed in refspec: "%s"' % refspec_suffix) |
2491 refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix) | 2497 refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix) |
2492 | 2498 |
2493 push_stdout = gclient_utils.CheckCallAndFilter( | 2499 push_stdout = gclient_utils.CheckCallAndFilter( |
2494 ['git', 'push', gerrit_remote, refspec], | 2500 ['git', 'push', gerrit_remote, refspec], |
2495 print_stdout=True, | 2501 print_stdout=True, |
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4901 if __name__ == '__main__': | 4907 if __name__ == '__main__': |
4902 # These affect sys.stdout so do it outside of main() to simplify mocks in | 4908 # These affect sys.stdout so do it outside of main() to simplify mocks in |
4903 # unit testing. | 4909 # unit testing. |
4904 fix_encoding.fix_encoding() | 4910 fix_encoding.fix_encoding() |
4905 setup_color.init() | 4911 setup_color.init() |
4906 try: | 4912 try: |
4907 sys.exit(main(sys.argv[1:])) | 4913 sys.exit(main(sys.argv[1:])) |
4908 except KeyboardInterrupt: | 4914 except KeyboardInterrupt: |
4909 sys.stderr.write('interrupted\n') | 4915 sys.stderr.write('interrupted\n') |
4910 sys.exit(1) | 4916 sys.exit(1) |
OLD | NEW |