Chromium Code Reviews| 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 2466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2477 if not options.download_base: | 2477 if not options.download_base: |
| 2478 form_fields.append(("content_upload", "1")) | 2478 form_fields.append(("content_upload", "1")) |
| 2479 if len(data) > MAX_UPLOAD_SIZE: | 2479 if len(data) > MAX_UPLOAD_SIZE: |
| 2480 print "Patch is large, so uploading file patches separately." | 2480 print "Patch is large, so uploading file patches separately." |
| 2481 uploaded_diff_file = [] | 2481 uploaded_diff_file = [] |
| 2482 form_fields.append(("separate_patches", "1")) | 2482 form_fields.append(("separate_patches", "1")) |
| 2483 else: | 2483 else: |
| 2484 uploaded_diff_file = [("data", "data.diff", data)] | 2484 uploaded_diff_file = [("data", "data.diff", data)] |
| 2485 ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file) | 2485 ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file) |
| 2486 response_body = rpc_server.Send("/upload", body, content_type=ctype) | 2486 response_body = rpc_server.Send("/upload", body, content_type=ctype) |
| 2487 patchset = None | 2487 issue, patchset = None, None |
| 2488 if not options.download_base or not uploaded_diff_file: | 2488 if not options.download_base or not uploaded_diff_file: |
| 2489 lines = response_body.splitlines() | 2489 lines = response_body.splitlines() |
| 2490 if len(lines) >= 2: | 2490 if len(lines) >= 2: |
| 2491 msg = lines[0] | 2491 # lines[0] is "Issue (created|updated): <url>". |
| 2492 issue = lines[0][lines[0].rfind("/")+1:] | |
| 2493 # lines[1] is just patchset number. | |
| 2492 patchset = lines[1].strip() | 2494 patchset = lines[1].strip() |
| 2495 msg = '%s (patchset: %s)' % (lines[0], patchset) | |
| 2493 patches = [x.split(" ", 1) for x in lines[2:]] | 2496 patches = [x.split(" ", 1) for x in lines[2:]] |
| 2494 else: | 2497 else: |
| 2495 msg = response_body | 2498 msg = response_body |
| 2496 else: | 2499 else: |
| 2497 msg = response_body | 2500 msg = response_body |
| 2498 StatusUpdate(msg) | 2501 StatusUpdate(msg) |
| 2499 if not response_body.startswith("Issue created.") and \ | 2502 if not response_body.startswith("Issue created.") and \ |
| 2500 not response_body.startswith("Issue updated."): | 2503 not response_body.startswith("Issue updated."): |
| 2501 sys.exit(0) | 2504 sys.exit(0) |
| 2502 issue = msg[msg.rfind("/")+1:] | 2505 assert issue |
|
Bons
2016/03/08 18:48:22
this is meant to be in here?
tandrii(chromium)
2016/03/08 19:02:47
Yes, as I slightly changed logical conditions from
| |
| 2503 | 2506 |
| 2504 if not uploaded_diff_file: | 2507 if not uploaded_diff_file: |
| 2505 result = UploadSeparatePatches(issue, rpc_server, patchset, data, options) | 2508 result = UploadSeparatePatches(issue, rpc_server, patchset, data, options) |
| 2506 if not options.download_base: | 2509 if not options.download_base: |
| 2507 patches = result | 2510 patches = result |
| 2508 | 2511 |
| 2509 if not options.download_base: | 2512 if not options.download_base: |
| 2510 vcs.UploadBaseFiles(issue, rpc_server, patches, patchset, options, files) | 2513 vcs.UploadBaseFiles(issue, rpc_server, patches, patchset, options, files) |
| 2511 | 2514 |
| 2512 payload = {} # payload for final request | 2515 payload = {} # payload for final request |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2532 print | 2535 print |
| 2533 StatusUpdate("Interrupted.") | 2536 StatusUpdate("Interrupted.") |
| 2534 sys.exit(1) | 2537 sys.exit(1) |
| 2535 except auth.AuthenticationError as e: | 2538 except auth.AuthenticationError as e: |
| 2536 print >> sys.stderr, e | 2539 print >> sys.stderr, e |
| 2537 sys.exit(1) | 2540 sys.exit(1) |
| 2538 | 2541 |
| 2539 | 2542 |
| 2540 if __name__ == "__main__": | 2543 if __name__ == "__main__": |
| 2541 main() | 2544 main() |
| OLD | NEW |