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 import datetime | 10 import datetime |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 items = path.split('@') | 90 items = path.split('@') |
91 assert len(items) <= 2 | 91 assert len(items) <= 2 |
92 self.checkout_root = items[0] | 92 self.checkout_root = items[0] |
93 items.append(None) | 93 items.append(None) |
94 self.diff_against = items[1] | 94 self.diff_against = items[1] |
95 self.options = options | 95 self.options = options |
96 self.files = self.options.files | 96 self.files = self.options.files |
97 self.options.files = None | 97 self.options.files = None |
98 self.codereview_settings = None | 98 self.codereview_settings = None |
99 self.codereview_settings_file = 'codereview.settings' | 99 self.codereview_settings_file = 'codereview.settings' |
| 100 self.gclient_root = None |
100 | 101 |
101 def GetFileNames(self): | 102 def GetFileNames(self): |
102 """Return the list of files in the diff.""" | 103 """Return the list of files in the diff.""" |
103 return self.files | 104 return self.files |
104 | 105 |
105 def GetCodeReviewSetting(self, key): | 106 def GetCodeReviewSetting(self, key): |
106 """Returns a value for the given key for this repository. | 107 """Returns a value for the given key for this repository. |
107 | 108 |
108 Uses gcl-style settings from the repository.""" | 109 Uses gcl-style settings from the repository.""" |
109 if self.codereview_settings is None: | 110 if self.codereview_settings is None: |
(...skipping 19 matching lines...) Expand all Loading... |
129 'patchlevel': self.GetCodeReviewSetting('TRYSERVER_PATCHLEVEL'), | 130 'patchlevel': self.GetCodeReviewSetting('TRYSERVER_PATCHLEVEL'), |
130 } | 131 } |
131 logging.info('\n'.join(['%s: %s' % (k, v) | 132 logging.info('\n'.join(['%s: %s' % (k, v) |
132 for (k, v) in settings.iteritems() if v])) | 133 for (k, v) in settings.iteritems() if v])) |
133 for (k, v) in settings.iteritems(): | 134 for (k, v) in settings.iteritems(): |
134 if v and getattr(self.options, k) is None: | 135 if v and getattr(self.options, k) is None: |
135 setattr(self.options, k, v) | 136 setattr(self.options, k, v) |
136 | 137 |
137 def _GclientStyleSettings(self): | 138 def _GclientStyleSettings(self): |
138 """Find the root, assuming a gclient-style checkout.""" | 139 """Find the root, assuming a gclient-style checkout.""" |
139 self.gclient_root = None | |
140 if not self.options.no_gclient and not self.options.root: | 140 if not self.options.no_gclient and not self.options.root: |
141 root = self.checkout_root | 141 root = self.checkout_root |
142 self.gclient_root = gclient_utils.FindGclientRoot(root) | 142 self.gclient_root = gclient_utils.FindGclientRoot(root) |
143 if self.gclient_root: | 143 if self.gclient_root: |
144 logging.info('Found .gclient at %s' % self.gclient_root) | 144 logging.info('Found .gclient at %s' % self.gclient_root) |
145 self.options.root = gclient_utils.PathDifference(self.gclient_root, | 145 self.options.root = gclient_utils.PathDifference(self.gclient_root, |
146 root) | 146 root) |
147 | 147 |
148 def AutomagicalSettings(self): | 148 def AutomagicalSettings(self): |
149 """Determines settings based on supported code review and checkout tools. | 149 """Determines settings based on supported code review and checkout tools. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 def _SendChangeHTTP(options): | 294 def _SendChangeHTTP(options): |
295 """Send a change to the try server using the HTTP protocol.""" | 295 """Send a change to the try server using the HTTP protocol.""" |
296 if not options.host: | 296 if not options.host: |
297 raise NoTryServerAccess('Please use the --host option to specify the try ' | 297 raise NoTryServerAccess('Please use the --host option to specify the try ' |
298 'server host to connect to.') | 298 'server host to connect to.') |
299 if not options.port: | 299 if not options.port: |
300 raise NoTryServerAccess('Please use the --port option to specify the try ' | 300 raise NoTryServerAccess('Please use the --port option to specify the try ' |
301 'server port to connect to.') | 301 'server port to connect to.') |
302 | 302 |
303 values = _ParseSendChangeOptions(options) | 303 values = _ParseSendChangeOptions(options) |
304 description = ''.join("%s=%s\n" % (k,v) for (k,v) in values.iteritems()) | 304 description = ''.join("%s=%s\n" % (k, v) for (k, v) in values.iteritems()) |
305 values['patch'] = options.diff | 305 values['patch'] = options.diff |
306 | 306 |
307 url = 'http://%s:%s/send_try_patch' % (options.host, options.port) | 307 url = 'http://%s:%s/send_try_patch' % (options.host, options.port) |
308 proxies = None | 308 proxies = None |
309 if options.proxy: | 309 if options.proxy: |
310 if options.proxy.lower() == 'none': | 310 if options.proxy.lower() == 'none': |
311 # Effectively disable HTTP_PROXY or Internet settings proxy setup. | 311 # Effectively disable HTTP_PROXY or Internet settings proxy setup. |
312 proxies = {} | 312 proxies = {} |
313 else: | 313 else: |
314 proxies = {'http': options.proxy, 'https': options.proxy} | 314 proxies = {'http': options.proxy, 'https': options.proxy} |
(...skipping 23 matching lines...) Expand all Loading... |
338 | 338 |
339 | 339 |
340 def _SendChangeSVN(options): | 340 def _SendChangeSVN(options): |
341 """Send a change to the try server by committing a diff file on a subversion | 341 """Send a change to the try server by committing a diff file on a subversion |
342 server.""" | 342 server.""" |
343 if not options.svn_repo: | 343 if not options.svn_repo: |
344 raise NoTryServerAccess('Please use the --svn_repo option to specify the' | 344 raise NoTryServerAccess('Please use the --svn_repo option to specify the' |
345 ' try server svn repository to connect to.') | 345 ' try server svn repository to connect to.') |
346 | 346 |
347 values = _ParseSendChangeOptions(options) | 347 values = _ParseSendChangeOptions(options) |
348 description = ''.join("%s=%s\n" % (k,v) for (k,v) in values.iteritems()) | 348 description = ''.join("%s=%s\n" % (k, v) for (k, v) in values.iteritems()) |
349 logging.info('Sending by SVN') | 349 logging.info('Sending by SVN') |
350 logging.info(description) | 350 logging.info(description) |
351 logging.info(options.svn_repo) | 351 logging.info(options.svn_repo) |
352 logging.info(options.diff) | 352 logging.info(options.diff) |
353 if options.dry_run: | 353 if options.dry_run: |
354 return | 354 return |
355 | 355 |
356 # Create a temporary directory, put a uniquely named file in it with the diff | 356 # Create a temporary directory, put a uniquely named file in it with the diff |
357 # content and svn import that. | 357 # content and svn import that. |
358 temp_dir = tempfile.mkdtemp() | 358 temp_dir = tempfile.mkdtemp() |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 except (InvalidScript, NoTryServerAccess), e: | 752 except (InvalidScript, NoTryServerAccess), e: |
753 if swallow_exception: | 753 if swallow_exception: |
754 return 1 | 754 return 1 |
755 print e | 755 print e |
756 return 1 | 756 return 1 |
757 return 0 | 757 return 0 |
758 | 758 |
759 | 759 |
760 if __name__ == "__main__": | 760 if __name__ == "__main__": |
761 sys.exit(TryChange(None, [], False)) | 761 sys.exit(TryChange(None, [], False)) |
OLD | NEW |