Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(150)

Delta Between Two Patch Sets: static/upload.py

Issue 955: Allow upload with no base (Closed) SVN Base: http://rietveld.googlecode.com/svn/trunk/
Left Patch Set: Created 4 months, 4 weeks ago
Right Patch Set: I incorporated the changes as per your comments in previous patch. Created 4 months, 4 weeks ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2007 Google Inc. 3 # Copyright 2007 Google Inc.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 343 matching lines...) Show 10 above Show 10 below
354 parser.add_option("--no_cookies", action="store_false", 354 parser.add_option("--no_cookies", action="store_false",
355 dest="save_cookies", default=True, 355 dest="save_cookies", default=True,
356 help="Do not save authentication cookies to local disk.") 356 help="Do not save authentication cookies to local disk.")
357 parser.add_option("-m", "--message", action="store", dest="message", 357 parser.add_option("-m", "--message", action="store", dest="message",
358 metavar="MESSAGE", default=None, 358 metavar="MESSAGE", default=None,
359 help="A message to identify the patch. " 359 help="A message to identify the patch. "
360 "Will prompt if omitted.") 360 "Will prompt if omitted.")
361 parser.add_option("-i", "--issue", type="int", action="store", 361 parser.add_option("-i", "--issue", type="int", action="store",
362 metavar="ISSUE", default=None, 362 metavar="ISSUE", default=None,
363 help="Issue number to which to add. Defaults to new issue.") 363 help="Issue number to which to add. Defaults to new issue.")
364 parser.add_option("--lb", action="store_true", 364 parser.add_option("-l", "--local_base", action="store_true",
GvR 2008/05/17 03:29:02 I recommend "-l", "--local_base"
365 dest="local_base", default=False, 365 dest="local_base", default=False,
366 help="base file will be uploaded") 366 help="base file will be uploaded")
367 367
368 368
369 def GetRpcServer(options): 369 def GetRpcServer(options):
370 """Returns an instance of an AbstractRpcServer. 370 """Returns an instance of an AbstractRpcServer.
371 371
372 Returns: 372 Returns:
373 A new AbstractRpcServer, on which RPC calls can be made. 373 A new AbstractRpcServer, on which RPC calls can be made.
374 """ 374 """
(...skipping 117 matching lines...) Show 10 above Show 10 below
492 logging.basicConfig(format=("%(asctime).19s %(levelname)s %(filename)s:" 492 logging.basicConfig(format=("%(asctime).19s %(levelname)s %(filename)s:"
493 "%(lineno)s %(message)s ")) 493 "%(lineno)s %(message)s "))
494 options, args = parser.parse_args(sys.argv[1:]) 494 options, args = parser.parse_args(sys.argv[1:])
495 global verbosity 495 global verbosity
496 verbosity = options.verbose 496 verbosity = options.verbose
497 if verbosity >= 3: 497 if verbosity >= 3:
498 logging.getLogger().setLevel(logging.DEBUG) 498 logging.getLogger().setLevel(logging.DEBUG)
499 elif verbosity >= 2: 499 elif verbosity >= 2:
500 logging.getLogger().setLevel(logging.INFO) 500 logging.getLogger().setLevel(logging.INFO)
501 if options.local_base: 501 if options.local_base:
502 base = "None" 502 base = None
GvR 2008/05/17 03:29:02 I'd set it to the empty string. That should be tur
503 else: 503 else:
504 base = GuessBase() 504 base = GuessBase()
505 CheckForUnknownFiles() 505 CheckForUnknownFiles()
506 data = RunShell("svn diff", args) 506 data = RunShell("svn diff", args)
507 count = 0 507 count = 0
508 for line in data.splitlines(): 508 for line in data.splitlines():
509 if line.startswith("Index:"): 509 if line.startswith("Index:"):
510 count += 1 510 count += 1
511 logging.info(line) 511 logging.info(line)
512 if not count: 512 if not count:
513 ErrorExit("No valid patches found in output from svn diff") 513 ErrorExit("No valid patches found in output from svn diff")
514 if options.issue: 514 if options.issue:
515 prompt = "Message describing this patch set: " 515 prompt = "Message describing this patch set: "
516 else: 516 else:
517 prompt = "New issue subject: " 517 prompt = "New issue subject: "
518 message = options.message or raw_input(prompt).strip() 518 message = options.message or raw_input(prompt).strip()
519 if not message: 519 if not message:
520 ErrorExit("A non-empty message is required") 520 ErrorExit("A non-empty message is required")
521 rpc_server = GetRpcServer(options) 521 rpc_server = GetRpcServer(options)
522 form_fields = [("base", base), ("subject", message)] 522 form_fields = [("subject", message)]
523 if base is not None:
524 form_fields.append(("base", base))
523 if options.issue: 525 if options.issue:
524 form_fields.append(("issue", str(options.issue))) 526 form_fields.append(("issue", str(options.issue)))
525 if options.email: 527 if options.email:
526 form_fields.append(("user", options.email)) 528 form_fields.append(("user", options.email))
527 ctype, body = EncodeMultipartFormData(form_fields, 529 ctype, body = EncodeMultipartFormData(form_fields,
528 [("data", "data.diff", data)]) 530 [("data", "data.diff", data)])
529 response_body = rpc_server.Send("/upload", body, content_type=ctype) 531 response_body = rpc_server.Send("/upload", body, content_type=ctype)
530 StatusUpdate(response_body) 532 StatusUpdate(response_body)
531 sys.exit(not response_body.startswith("Issue created.")) 533 sys.exit(not response_body.startswith("Issue created."))
532 534
(...skipping 16 matching lines...) Show 10 above Show 10 below
549 try: 551 try:
550 RealMain(sys.argv) 552 RealMain(sys.argv)
551 except KeyboardInterrupt: 553 except KeyboardInterrupt:
552 print 554 print
553 StatusUpdate("Interrupted.") 555 StatusUpdate("Interrupted.")
554 sys.exit(1) 556 sys.exit(1)
555 557
556 558
557 if __name__ == "__main__": 559 if __name__ == "__main__":
558 main() 560 main()
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r338