Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: hgreview.py

Issue 29363768: Fixes 4662 - [hgreview] Add an option for suppressing the email after upload (Closed) Base URL: https://bitbucket.org/fhd/codingtools
Patch Set: Use ui.status instead of print Created Nov. 23, 2016, 5:20 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import BaseHTTPServer 1 import BaseHTTPServer
2 import os 2 import os
3 import re 3 import re
4 import socket 4 import socket
5 import sys 5 import sys
6 import urllib 6 import urllib
7 7
8 from mercurial import cmdutil, error 8 from mercurial import cmdutil, error
9 9
10 SERVER = 'https://codereview.adblockplus.org' 10 SERVER = 'https://codereview.adblockplus.org'
11 UPLOADTOOL_URL = SERVER + '/static/upload.py' 11 UPLOADTOOL_URL = SERVER + '/static/upload.py'
12 12
13 cmdtable = {} 13 cmdtable = {}
14 command = cmdutil.command(cmdtable) 14 command = cmdutil.command(cmdtable)
15 15
16 16
17 @command('review', 17 @command('review',
18 [ 18 [
19 ('i', 'issue', '', 'If given, adds a patch set to this review, othe rwise create a new one.', 'ISSUE'), 19 ('i', 'issue', '', 'If given, adds a patch set to this review, othe rwise create a new one.', 'ISSUE'),
20 ('r', 'revision', '', 'Revision to diff against or a revision range to upload.', 'REV'), 20 ('r', 'revision', '', 'Revision to diff against or a revision range to upload.', 'REV'),
21 ('c', 'change', '', 'A single revision to upload.', 'REV'), 21 ('c', 'change', '', 'A single revision to upload.', 'REV'),
22 ('t', 'title', '', 'New review subject or new patch set title.', 'T ITLE'), 22 ('t', 'title', '', 'New review subject or new patch set title.', 'T ITLE'),
23 ('m', 'message', '', 'New review description or new patch set messa ge.', 'MESSAGE'), 23 ('m', 'message', '', 'New review description or new patch set messa ge.', 'MESSAGE'),
24 ('w', 'reviewers', '', 'Add reviewers (comma separated email addres ses or @adblockplus.org user names).', 'REVIEWERS'), 24 ('w', 'reviewers', '', 'Add reviewers (comma separated email addres ses or @adblockplus.org user names).', 'REVIEWERS'),
25 ('', 'cc', '', 'Add CC (comma separated email addresses or @adblock plus.org user names).', 'CC'), 25 ('', 'cc', '', 'Add CC (comma separated email addresses or @adblock plus.org user names).', 'CC'),
26 ('', 'private', None, 'Make the review restricted to reviewers and those CCed.'), 26 ('', 'private', None, 'Make the review restricted to reviewers and those CCed.'),
27 ('y', 'assume_yes', None, 'Assume that the answer to yes/no questio ns is \'yes\'.'), 27 ('y', 'assume_yes', None, 'Assume that the answer to yes/no questio ns is \'yes\'.'),
28 ('', 'print_diffs', None, 'Print full diffs.'), 28 ('', 'print_diffs', None, 'Print full diffs.'),
29 ('', 'no_mail', None, 'Don\'t send an email after uploading.'),
29 ], '[options] [path...]') 30 ], '[options] [path...]')
30 def review(ui, repo, *paths, **opts): 31 def review(ui, repo, *paths, **opts):
31 ''' 32 '''
32 Uploads a review to https://codereview.adblockplus.org/ or updates an 33 Uploads a review to https://codereview.adblockplus.org/ or updates an
33 existing review request. This will always send mails for new reviews, when 34 existing review request. This will always send mails for new reviews, when
34 updating a review mails will only be sent if a message is given. 35 updating a review mails will only be sent if a message is given.
35 ''' 36 '''
36 args = ['--oauth2', '--server', SERVER] 37 args = ['--oauth2', '--server', SERVER]
37 if ui.debugflag: 38 if ui.debugflag:
38 args.append('--noisy') 39 args.append('--noisy')
39 elif ui.verbose: 40 elif ui.verbose:
40 args.append('--verbose') 41 args.append('--verbose')
41 elif ui.quiet: 42 elif ui.quiet:
42 args.append('--quiet') 43 args.append('--quiet')
43 44
44 if not opts.get('issue') or opts.get('message'): 45 if (not opts.get('no_mail') and
46 (not opts.get('issue') or opts.get('message'))):
45 args.append('--send_mail') 47 args.append('--send_mail')
46 48
47 if opts.get('revision') and opts.get('change'): 49 if opts.get('revision') and opts.get('change'):
48 raise error.Abort('Ambiguous revision range, only one of --revision and --change can be specified.') 50 raise error.Abort('Ambiguous revision range, only one of --revision and --change can be specified.')
49 if opts.get('change'): 51 if opts.get('change'):
50 rev = repo[opts['change']] 52 rev = repo[opts['change']]
51 args.extend(['--rev', '{}:{}'.format(rev.parents()[0], rev)]) 53 args.extend(['--rev', '{}:{}'.format(rev.parents()[0], rev)])
52 elif opts.get('revision'): 54 elif opts.get('revision'):
53 args.extend(['--rev', opts['revision']]) 55 args.extend(['--rev', opts['revision']])
54 else: 56 else:
(...skipping 13 matching lines...) Expand all
68 70
69 path = (ui.config('paths', 'default-push') 71 path = (ui.config('paths', 'default-push')
70 or ui.config('paths', 'default') 72 or ui.config('paths', 'default')
71 or '') 73 or '')
72 match = re.search(r'^(?:https://|ssh://hg@)(.*)', path) 74 match = re.search(r'^(?:https://|ssh://hg@)(.*)', path)
73 if match: 75 if match:
74 opts['base_url'] = 'https://' + match.group(1) 76 opts['base_url'] = 'https://' + match.group(1)
75 77
76 # Make sure there is at least one reviewer 78 # Make sure there is at least one reviewer
77 if not opts.get('reviewers'): 79 if not opts.get('reviewers'):
78 opts['reviewers'] = ui.prompt('Reviewers (comma-separated): ', '') 80 if opts.get('no_mail'):
79 if not opts['reviewers'].strip(): 81 ui.status('No reviewers specified, edit the review to add '
80 raise error.Abort('No reviewers given.') 82 'some.\n')
83 else:
84 opts['reviewers'] = ui.prompt('Reviewers (comma-separated): ',
85 '')
86 if not opts['reviewers'].strip():
87 raise error.Abort('No reviewers given.')
81 88
82 for opt in ('reviewers', 'cc'): 89 for opt in ('reviewers', 'cc'):
83 if opts.get(opt): 90 if opts.get(opt):
84 users = [u if '@' in u else u + '@adblockplus.org' 91 users = [u if '@' in u else u + '@adblockplus.org'
85 for u in re.split(r'\s*,\s*', opts[opt])] 92 for u in re.split(r'\s*,\s*', opts[opt])]
86 opts[opt] = ','.join(users) 93 opts[opt] = ','.join(users)
87 94
88 for opt in ('issue', 'title', 'message', 'reviewers', 'cc', 'base_url'): 95 for opt in ('issue', 'title', 'message', 'reviewers', 'cc', 'base_url'):
89 if opts.get(opt, ''): 96 if opts.get(opt, ''):
90 args.extend(['--' + opt, opts[opt]]) 97 args.extend(['--' + opt, opts[opt]])
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 </body> 156 </body>
150 </html> 157 </html>
151 ''' % port 158 ''' % port
152 159
153 # Run the upload tool 160 # Run the upload tool
154 issue, patchset = scope['RealMain']([upload_path] + args) 161 issue, patchset = scope['RealMain']([upload_path] + args)
155 162
156 # Wait for the page to check in and retrieve issue URL 163 # Wait for the page to check in and retrieve issue URL
157 if server: 164 if server:
158 server.handle_request() 165 server.handle_request()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld