OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 """Client-side script to send a try job to the try server. It communicates to | 5 """Client-side script to send a try job to the try server. It communicates to |
6 the try server by either writting to a svn repository or by directly connecting | 6 the try server by either writting to a svn repository or by directly connecting |
7 to the server by HTTP. | 7 to the server by HTTP. |
8 """ | 8 """ |
9 | 9 |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 try: | 87 try: |
88 return socket.getaddrinfo(host, None) | 88 return socket.getaddrinfo(host, None) |
89 except socket.gaierror: | 89 except socket.gaierror: |
90 return None | 90 return None |
91 | 91 |
92 settings = {} | 92 settings = {} |
93 settings['http_port'] = gcl.GetCodeReviewSetting('TRYSERVER_HTTP_PORT') | 93 settings['http_port'] = gcl.GetCodeReviewSetting('TRYSERVER_HTTP_PORT') |
94 settings['http_host'] = gcl.GetCodeReviewSetting('TRYSERVER_HTTP_HOST') | 94 settings['http_host'] = gcl.GetCodeReviewSetting('TRYSERVER_HTTP_HOST') |
95 settings['svn_repo'] = gcl.GetCodeReviewSetting('TRYSERVER_SVN_URL') | 95 settings['svn_repo'] = gcl.GetCodeReviewSetting('TRYSERVER_SVN_URL') |
96 settings['default_project'] = gcl.GetCodeReviewSetting('TRYSERVER_PROJECT') | 96 settings['default_project'] = gcl.GetCodeReviewSetting('TRYSERVER_PROJECT') |
| 97 settings['default_root'] = gcl.GetCodeReviewSetting('TRYSERVER_ROOT') |
| 98 |
| 99 # Pick a patchlevel, default to 0. |
| 100 default_patchlevel = gcl.GetCodeReviewSetting('TRYSERVER_PATCHLEVEL') |
| 101 if default_patchlevel: |
| 102 default_patchlevel = int(default_patchlevel) |
| 103 else: |
| 104 default_patchlevel = 0 |
| 105 settings['default_patchlevel'] = default_patchlevel |
| 106 |
97 # Use http is the http_host name resolve, fallback to svn otherwise. | 107 # Use http is the http_host name resolve, fallback to svn otherwise. |
98 if (settings['http_port'] and settings['http_host'] and | 108 if (settings['http_port'] and settings['http_host'] and |
99 _SafeResolve(settings['http_host'])): | 109 _SafeResolve(settings['http_host'])): |
100 settings['default_transport'] = 'http' | 110 settings['default_transport'] = 'http' |
101 elif settings.get('svn_repo'): | 111 elif settings.get('svn_repo'): |
102 settings['default_transport'] = 'svn' | 112 settings['default_transport'] = 'svn' |
103 return settings | 113 return settings |
104 | 114 |
105 | 115 |
106 def EscapeDot(name): | 116 def EscapeDot(name): |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 group.add_option("-f", "--file", default=file_list, dest="files", | 465 group.add_option("-f", "--file", default=file_list, dest="files", |
456 metavar="FILE", action="append", | 466 metavar="FILE", action="append", |
457 help="Use many times to list the files to include in the " | 467 help="Use many times to list the files to include in the " |
458 "try, relative to the repository root") | 468 "try, relative to the repository root") |
459 group.add_option("--diff", | 469 group.add_option("--diff", |
460 help="File containing the diff to try") | 470 help="File containing the diff to try") |
461 group.add_option("--url", | 471 group.add_option("--url", |
462 help="Url where to grab a patch") | 472 help="Url where to grab a patch") |
463 group.add_option("--root", | 473 group.add_option("--root", |
464 help="Root to use for the patch; base subdirectory for " | 474 help="Root to use for the patch; base subdirectory for " |
465 "patch created in a subdirectory") | 475 "patch created in a subdirectory", |
| 476 default=default_settings["default_root"]) |
466 group.add_option("--patchlevel", type='int', metavar="LEVEL", | 477 group.add_option("--patchlevel", type='int', metavar="LEVEL", |
467 help="Used as -pN parameter to patch") | 478 help="Used as -pN parameter to patch", |
| 479 default=default_settings["default_patchlevel"]) |
468 parser.add_option_group(group) | 480 parser.add_option_group(group) |
469 | 481 |
470 group = optparse.OptionGroup(parser, "Access the try server by HTTP") | 482 group = optparse.OptionGroup(parser, "Access the try server by HTTP") |
471 group.add_option("--use_http", | 483 group.add_option("--use_http", |
472 action="store_const", | 484 action="store_const", |
473 const=_SendChangeHTTP, | 485 const=_SendChangeHTTP, |
474 dest="send_patch", | 486 dest="send_patch", |
475 default=default_transport, | 487 default=default_transport, |
476 help="Use HTTP to talk to the try server [default]") | 488 help="Use HTTP to talk to the try server [default]") |
477 group.add_option("--host", | 489 group.add_option("--host", |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 if patch_name == 'Unnamed': | 548 if patch_name == 'Unnamed': |
537 print "Note: use --name NAME to change the try's name." | 549 print "Note: use --name NAME to change the try's name." |
538 except (InvalidScript, NoTryServerAccess), e: | 550 except (InvalidScript, NoTryServerAccess), e: |
539 if swallow_exception: | 551 if swallow_exception: |
540 return | 552 return |
541 print e | 553 print e |
542 | 554 |
543 | 555 |
544 if __name__ == "__main__": | 556 if __name__ == "__main__": |
545 TryChange(None, None, False) | 557 TryChange(None, None, False) |
OLD | NEW |