Index: hgreview.py |
=================================================================== |
--- a/hgreview.py |
+++ b/hgreview.py |
@@ -21,32 +21,34 @@ |
('c', 'change', '', 'A single revision to upload.', 'REV'), |
('t', 'title', '', 'New review subject or new patch set title.', 'TITLE'), |
('m', 'message', '', 'New review description or new patch set message.', 'MESSAGE'), |
('w', 'reviewers', '', 'Add reviewers (comma separated email addresses or @adblockplus.org user names).', 'REVIEWERS'), |
('', 'cc', '', 'Add CC (comma separated email addresses or @adblockplus.org user names).', 'CC'), |
('', 'private', None, 'Make the review restricted to reviewers and those CCed.'), |
('y', 'assume_yes', None, 'Assume that the answer to yes/no questions is \'yes\'.'), |
('', 'print_diffs', None, 'Print full diffs.'), |
+ ('', 'no_mail', None, 'Don\'t send an email after uploading.', 'NO_MAIL'), |
Wladimir Palant
2016/11/22 15:39:35
This is a flag without any parameter - please drop
Felix Dahlke
2016/11/23 05:46:48
Done.
|
], '[options] [path...]') |
def review(ui, repo, *paths, **opts): |
''' |
Uploads a review to https://codereview.adblockplus.org/ or updates an |
existing review request. This will always send mails for new reviews, when |
updating a review mails will only be sent if a message is given. |
''' |
args = ['--oauth2', '--server', SERVER] |
if ui.debugflag: |
args.append('--noisy') |
elif ui.verbose: |
args.append('--verbose') |
elif ui.quiet: |
args.append('--quiet') |
- if not opts.get('issue') or opts.get('message'): |
+ if (not opts.get("no_mail") and |
Vasily Kuznetsov
2016/11/22 15:29:35
According to our style guide this string should be
Felix Dahlke
2016/11/23 05:46:48
Whoops, something I'll have to get used to :P Done
|
+ (not opts.get('issue') or opts.get('message'))): |
Vasily Kuznetsov
2016/11/22 15:29:35
Flake8 also gives E129 on this line (suggesting to
Felix Dahlke
2016/11/23 05:46:48
Forgout about the whole flake8 thing. Running it o
Vasily Kuznetsov
2016/11/23 11:00:28
For me it seemed to work with an additional 4-spac
|
args.append('--send_mail') |
if opts.get('revision') and opts.get('change'): |
raise error.Abort('Ambiguous revision range, only one of --revision and --change can be specified.') |
if opts.get('change'): |
rev = repo[opts['change']] |
args.extend(['--rev', '{}:{}'.format(rev.parents()[0], rev)]) |
elif opts.get('revision'): |
@@ -68,21 +70,22 @@ |
path = (ui.config('paths', 'default-push') |
or ui.config('paths', 'default') |
or '') |
match = re.search(r'^(?:https://|ssh://hg@)(.*)', path) |
if match: |
opts['base_url'] = 'https://' + match.group(1) |
- # Make sure there is at least one reviewer |
- if not opts.get('reviewers'): |
- opts['reviewers'] = ui.prompt('Reviewers (comma-separated): ', '') |
- if not opts['reviewers'].strip(): |
- raise error.Abort('No reviewers given.') |
+ if not opts.get('no_mail'): |
+ # Make sure there is at least one reviewer |
+ if not opts.get('reviewers'): |
+ opts['reviewers'] = ui.prompt('Reviewers (comma-separated): ', '') |
Vasily Kuznetsov
2016/11/22 15:29:35
This line is now 82 characters, so it probably wou
Wladimir Palant
2016/11/22 15:39:35
I'd still ask for reviewers here but accept empty
Felix Dahlke
2016/11/23 05:46:48
I personally prefer to add reviewers via the web i
Felix Dahlke
2016/11/23 05:46:48
I'm actually a pretty big fan of staying within th
Vasily Kuznetsov
2016/11/23 11:00:28
I share Felix's preference, probably because I'm b
Felix Dahlke
2016/11/23 11:36:04
Yeah same here, I'd really prefer it if we didn't
Wladimir Palant
2016/11/23 15:42:10
I guess that I could live with a warning.
Felix Dahlke
2016/11/23 16:06:03
Alright, gave that a go :) It's not incredibly int
|
+ if not opts['reviewers'].strip(): |
+ raise error.Abort('No reviewers given.') |
for opt in ('reviewers', 'cc'): |
if opts.get(opt): |
users = [u if '@' in u else u + '@adblockplus.org' |
for u in re.split(r'\s*,\s*', opts[opt])] |
opts[opt] = ','.join(users) |
for opt in ('issue', 'title', 'message', 'reviewers', 'cc', 'base_url'): |