summaryrefslogtreecommitdiffstats
path: root/subcmds/upload.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r--subcmds/upload.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 925652c2..a6ada337 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -13,6 +13,7 @@
13# See the License for the specific language governing permissions and 13# See the License for the specific language governing permissions and
14# limitations under the License. 14# limitations under the License.
15 15
16from __future__ import print_function
16import copy 17import copy
17import re 18import re
18import sys 19import sys
@@ -26,16 +27,18 @@ UNUSUAL_COMMIT_THRESHOLD = 5
26 27
27def _ConfirmManyUploads(multiple_branches=False): 28def _ConfirmManyUploads(multiple_branches=False):
28 if multiple_branches: 29 if multiple_branches:
29 print "ATTENTION: One or more branches has an unusually high number of commits." 30 print('ATTENTION: One or more branches has an unusually high number'
31 'of commits.')
30 else: 32 else:
31 print "ATTENTION: You are uploading an unusually high number of commits." 33 print('ATTENTION: You are uploading an unusually high number of commits.')
32 print "YOU PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across branches?)" 34 print('YOU PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across'
35 'branches?)')
33 answer = raw_input("If you are sure you intend to do this, type 'yes': ").strip() 36 answer = raw_input("If you are sure you intend to do this, type 'yes': ").strip()
34 return answer == "yes" 37 return answer == "yes"
35 38
36def _die(fmt, *args): 39def _die(fmt, *args):
37 msg = fmt % args 40 msg = fmt % args
38 print >>sys.stderr, 'error: %s' % msg 41 print('error: %s' % msg, file=sys.stderr)
39 sys.exit(1) 42 sys.exit(1)
40 43
41def _SplitEmails(values): 44def _SplitEmails(values):
@@ -176,14 +179,14 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
176 date = branch.date 179 date = branch.date
177 commit_list = branch.commits 180 commit_list = branch.commits
178 181
179 print 'Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr) 182 print('Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr))
180 print ' branch %s (%2d commit%s, %s):' % ( 183 print(' branch %s (%2d commit%s, %s):' % (
181 name, 184 name,
182 len(commit_list), 185 len(commit_list),
183 len(commit_list) != 1 and 's' or '', 186 len(commit_list) != 1 and 's' or '',
184 date) 187 date))
185 for commit in commit_list: 188 for commit in commit_list:
186 print ' %s' % commit 189 print(' %s' % commit)
187 190
188 sys.stdout.write('to %s (y/N)? ' % remote.review) 191 sys.stdout.write('to %s (y/N)? ' % remote.review)
189 answer = sys.stdin.readline().strip().lower() 192 answer = sys.stdin.readline().strip().lower()
@@ -317,7 +320,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
317 sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ') 320 sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ')
318 a = sys.stdin.readline().strip().lower() 321 a = sys.stdin.readline().strip().lower()
319 if a not in ('y', 'yes', 't', 'true', 'on'): 322 if a not in ('y', 'yes', 't', 'true', 'on'):
320 print >>sys.stderr, "skipping upload" 323 print("skipping upload", file=sys.stderr)
321 branch.uploaded = False 324 branch.uploaded = False
322 branch.error = 'User aborted' 325 branch.error = 'User aborted'
323 continue 326 continue
@@ -334,8 +337,8 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
334 branch.uploaded = False 337 branch.uploaded = False
335 have_errors = True 338 have_errors = True
336 339
337 print >>sys.stderr, '' 340 print(file=sys.stderr)
338 print >>sys.stderr, '----------------------------------------------------------------------' 341 print('----------------------------------------------------------------------', file=sys.stderr)
339 342
340 if have_errors: 343 if have_errors:
341 for branch in todo: 344 for branch in todo:
@@ -344,17 +347,19 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
344 fmt = ' (%s)' 347 fmt = ' (%s)'
345 else: 348 else:
346 fmt = '\n (%s)' 349 fmt = '\n (%s)'
347 print >>sys.stderr, ('[FAILED] %-15s %-15s' + fmt) % ( 350 print(('[FAILED] %-15s %-15s' + fmt) % (
348 branch.project.relpath + '/', \ 351 branch.project.relpath + '/', \
349 branch.name, \ 352 branch.name, \
350 str(branch.error)) 353 str(branch.error)),
351 print >>sys.stderr, '' 354 file=sys.stderr)
355 print()
352 356
353 for branch in todo: 357 for branch in todo:
354 if branch.uploaded: 358 if branch.uploaded:
355 print >>sys.stderr, '[OK ] %-15s %s' % ( 359 print('[OK ] %-15s %s' % (
356 branch.project.relpath + '/', 360 branch.project.relpath + '/',
357 branch.name) 361 branch.name),
362 file=sys.stderr)
358 363
359 if have_errors: 364 if have_errors:
360 sys.exit(1) 365 sys.exit(1)
@@ -385,7 +390,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
385 try: 390 try:
386 hook.Run(opt.allow_all_hooks, project_list=pending_proj_names) 391 hook.Run(opt.allow_all_hooks, project_list=pending_proj_names)
387 except HookError as e: 392 except HookError as e:
388 print >>sys.stderr, "ERROR: %s" % str(e) 393 print("ERROR: %s" % str(e), file=sys.stderr)
389 return 394 return
390 395
391 if opt.reviewers: 396 if opt.reviewers:
@@ -395,7 +400,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
395 people = (reviewers,cc) 400 people = (reviewers,cc)
396 401
397 if not pending: 402 if not pending:
398 print >>sys.stdout, "no branches ready for upload" 403 print("no branches ready for upload", file=sys.stderr)
399 elif len(pending) == 1 and len(pending[0][1]) == 1: 404 elif len(pending) == 1 and len(pending[0][1]) == 1:
400 self._SingleBranch(opt, pending[0][1][0], people) 405 self._SingleBranch(opt, pending[0][1][0], people)
401 else: 406 else: