OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 # | 3 # |
4 # Copyright 2007 Google Inc. | 4 # Copyright 2007 Google Inc. |
5 # | 5 # |
6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
9 # | 9 # |
10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 metavar="CC", default=None, | 625 metavar="CC", default=None, |
626 help="Add CC (comma separated email addresses).") | 626 help="Add CC (comma separated email addresses).") |
627 group.add_option("--private", action="store_true", dest="private", | 627 group.add_option("--private", action="store_true", dest="private", |
628 default=False, | 628 default=False, |
629 help="Make the issue restricted to reviewers and those CCed") | 629 help="Make the issue restricted to reviewers and those CCed") |
630 # Upload options | 630 # Upload options |
631 group = parser.add_option_group("Patch options") | 631 group = parser.add_option_group("Patch options") |
632 group.add_option("-i", "--issue", type="int", action="store", | 632 group.add_option("-i", "--issue", type="int", action="store", |
633 metavar="ISSUE", default=None, | 633 metavar="ISSUE", default=None, |
634 help="Issue number to which to add. Defaults to new issue.") | 634 help="Issue number to which to add. Defaults to new issue.") |
635 group.add_option("--base_url", action="store", dest="base_url", default=None, | |
636 help="Base URL path for files (listed as \"Base URL\" when " | |
637 "viewing issue). If omitted, will be guessed automatically " | |
638 "for SVN repos and left blank for others.") | |
639 group.add_option("--target_ref", action="store", dest="target_ref", | 635 group.add_option("--target_ref", action="store", dest="target_ref", |
640 default=None, | 636 default=None, |
641 help="The target ref that is transitively tracked by the " | 637 help="The target ref that is transitively tracked by the " |
642 "local branch this patch comes from.") | 638 "local branch this patch comes from.") |
643 parser.add_option("--cq_dry_run", action="store_true", | 639 parser.add_option("--cq_dry_run", action="store_true", |
644 help="Send the patchset to do a CQ dry run right after " | 640 help="Send the patchset to do a CQ dry run right after " |
645 "upload.") | 641 "upload.") |
646 parser.add_option("--depends_on_patchset", action="store", | 642 parser.add_option("--depends_on_patchset", action="store", |
647 dest="depends_on_patchset", | 643 dest="depends_on_patchset", |
648 help="The uploaded patchset this patchset depends on. The " | 644 help="The uploaded patchset this patchset depends on. The " |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 | 2362 |
2367 global verbosity | 2363 global verbosity |
2368 verbosity = options.verbose | 2364 verbosity = options.verbose |
2369 if verbosity >= 3: | 2365 if verbosity >= 3: |
2370 LOGGER.setLevel(logging.DEBUG) | 2366 LOGGER.setLevel(logging.DEBUG) |
2371 elif verbosity >= 2: | 2367 elif verbosity >= 2: |
2372 LOGGER.setLevel(logging.INFO) | 2368 LOGGER.setLevel(logging.INFO) |
2373 | 2369 |
2374 vcs = GuessVCS(options) | 2370 vcs = GuessVCS(options) |
2375 | 2371 |
2376 base = options.base_url | 2372 if options.download_base: |
2377 if isinstance(vcs, SubversionVCS): | |
2378 # Guessing the base field is only supported for Subversion. | |
2379 # Note: Fetching base files may become deprecated in future releases. | |
2380 guessed_base = vcs.GuessBase(options.download_base) | |
2381 if base: | |
2382 if guessed_base and base != guessed_base: | |
2383 print("Using base URL \"%s\" from --base_url instead of \"%s\"" % | |
2384 (base, guessed_base)) | |
2385 else: | |
2386 base = guessed_base | |
2387 | |
2388 if not base and options.download_base: | |
2389 options.download_base = True | 2373 options.download_base = True |
2390 LOGGER.info("Enabled upload of base file") | 2374 LOGGER.info("Enabled upload of base file") |
2391 if not options.assume_yes: | 2375 if not options.assume_yes: |
2392 vcs.CheckForUnknownFiles() | 2376 vcs.CheckForUnknownFiles() |
2393 if data is None: | 2377 if data is None: |
2394 data = vcs.GenerateDiff(args) | 2378 data = vcs.GenerateDiff(args) |
2395 data = vcs.PostProcessDiff(data) | 2379 data = vcs.PostProcessDiff(data) |
2396 if options.print_diffs: | 2380 if options.print_diffs: |
2397 print("Rietveld diff start:*****") | 2381 print("Rietveld diff start:*****") |
2398 print(data) | 2382 print(data) |
2399 print("Rietveld diff end:*****") | 2383 print("Rietveld diff end:*****") |
2400 files = vcs.GetBaseFiles(data) | 2384 files = vcs.GetBaseFiles(data) |
2401 if verbosity >= 1: | 2385 if verbosity >= 1: |
2402 print("Upload server:", options.server, "(change with -s/--server)") | 2386 print("Upload server:", options.server, "(change with -s/--server)") |
2403 | 2387 |
2404 auth_config = auth.extract_auth_config_from_options(options) | 2388 auth_config = auth.extract_auth_config_from_options(options) |
2405 rpc_server = GetRpcServer(options.server, auth_config, options.email) | 2389 rpc_server = GetRpcServer(options.server, auth_config, options.email) |
2406 form_fields = [] | 2390 form_fields = [] |
2407 | 2391 |
2408 repo_guid = vcs.GetGUID() | 2392 repo_guid = vcs.GetGUID() |
2409 if repo_guid: | 2393 if repo_guid: |
2410 form_fields.append(("repo_guid", repo_guid)) | 2394 form_fields.append(("repo_guid", repo_guid)) |
2411 if base: | |
2412 b = urlparse.urlparse(base) | |
2413 username, netloc = urllib.splituser(b.netloc) | |
2414 if username: | |
2415 LOGGER.info("Removed username from base URL") | |
2416 base = urlparse.urlunparse((b.scheme, netloc, b.path, b.params, | |
2417 b.query, b.fragment)) | |
2418 form_fields.append(("base", base)) | |
2419 if options.issue: | 2395 if options.issue: |
2420 form_fields.append(("issue", str(options.issue))) | 2396 form_fields.append(("issue", str(options.issue))) |
2421 if options.email: | 2397 if options.email: |
2422 form_fields.append(("user", options.email)) | 2398 form_fields.append(("user", options.email)) |
2423 if options.reviewers: | 2399 if options.reviewers: |
2424 for reviewer in options.reviewers.split(','): | 2400 for reviewer in options.reviewers.split(','): |
2425 CheckReviewer(reviewer) | 2401 CheckReviewer(reviewer) |
2426 form_fields.append(("reviewers", options.reviewers)) | 2402 form_fields.append(("reviewers", options.reviewers)) |
2427 if options.cc: | 2403 if options.cc: |
2428 for cc in options.cc.split(','): | 2404 for cc in options.cc.split(','): |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2552 print | 2528 print |
2553 StatusUpdate("Interrupted.") | 2529 StatusUpdate("Interrupted.") |
2554 sys.exit(1) | 2530 sys.exit(1) |
2555 except auth.AuthenticationError as e: | 2531 except auth.AuthenticationError as e: |
2556 print(e, file=sys.stderr) | 2532 print(e, file=sys.stderr) |
2557 sys.exit(1) | 2533 sys.exit(1) |
2558 | 2534 |
2559 | 2535 |
2560 if __name__ == "__main__": | 2536 if __name__ == "__main__": |
2561 main() | 2537 main() |
OLD | NEW |