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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 logging.info(description) | 329 logging.info(description) |
330 logging.info(url) | 330 logging.info(url) |
331 if options.dry_run: | 331 if options.dry_run: |
332 print options.diff | 332 print options.diff |
333 return | 333 return |
334 logging.info(options.diff) | 334 logging.info(options.diff) |
335 | 335 |
336 try: | 336 try: |
337 connection = urllib.urlopen(url, urllib.urlencode(values), proxies=proxies) | 337 connection = urllib.urlopen(url, urllib.urlencode(values), proxies=proxies) |
338 except IOError, e: | 338 except IOError, e: |
339 logging.warning(str(e)) | 339 logging.info(str(e)) |
340 if (values.get('bot') and len(e.args) > 2 and | 340 if (values.get('bot') and len(e.args) > 2 and |
341 e.args[2] == 'got a bad status line'): | 341 e.args[2] == 'got a bad status line'): |
342 raise NoTryServerAccess('%s is unaccessible. Bad --bot argument?' % url) | 342 raise NoTryServerAccess('%s is unaccessible. Bad --bot argument?' % url) |
343 else: | 343 else: |
344 raise NoTryServerAccess('%s is unaccessible. Reason: %s' % (url, | 344 raise NoTryServerAccess('%s is unaccessible. Reason: %s' % (url, |
345 str(e.args))) | 345 str(e.args))) |
346 if not connection: | 346 if not connection: |
347 raise NoTryServerAccess('%s is unaccessible.' % url) | 347 raise NoTryServerAccess('%s is unaccessible.' % url) |
348 response = connection.read() | 348 response = connection.read() |
349 if response != 'OK': | 349 if response != 'OK': |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 # Git has a command to test if you're in a git tree. | 437 # Git has a command to test if you're in a git tree. |
438 # Try running it, but don't die if we don't have git installed. | 438 # Try running it, but don't die if we don't have git installed. |
439 try: | 439 try: |
440 gclient_utils.CheckCall(['git', 'rev-parse', '--is-inside-work-tree'], | 440 gclient_utils.CheckCall(['git', 'rev-parse', '--is-inside-work-tree'], |
441 cwd=real_path) | 441 cwd=real_path) |
442 return GIT(options, path) | 442 return GIT(options, path) |
443 except gclient_utils.CheckCallError, e: | 443 except gclient_utils.CheckCallError, e: |
444 if e.returncode != errno.ENOENT and e.returncode != 128: | 444 if e.returncode != errno.ENOENT and e.returncode != 128: |
445 # ENOENT == 2 = they don't have git installed. | 445 # ENOENT == 2 = they don't have git installed. |
446 # 128 = git error code when not in a repo. | 446 # 128 = git error code when not in a repo. |
447 logging.warn('Unexpected error code: %s' % e.returncode) | 447 logging.warning('Unexpected error code: %s' % e.returncode) |
448 raise | 448 raise |
449 raise NoTryServerAccess("Could not guess version control system. " | 449 raise NoTryServerAccess("Could not guess version control system. " |
450 "Are you in a working copy directory?") | 450 "Are you in a working copy directory?") |
451 | 451 |
452 | 452 |
453 def GetMungedDiff(path_diff, diff): | 453 def GetMungedDiff(path_diff, diff): |
454 # Munge paths to match svn. | 454 # Munge paths to match svn. |
455 for i in range(len(diff)): | 455 for i in range(len(diff)): |
456 if diff[i].startswith('--- ') or diff[i].startswith('+++ '): | 456 if diff[i].startswith('--- ') or diff[i].startswith('+++ '): |
457 new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/') | 457 new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/') |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 print >> sys.stderr, e | 750 print >> sys.stderr, e |
751 return 1 | 751 return 1 |
752 except gclient_utils.Error, e: | 752 except gclient_utils.Error, e: |
753 print >> sys.stderr, e | 753 print >> sys.stderr, e |
754 return 1 | 754 return 1 |
755 return 0 | 755 return 0 |
756 | 756 |
757 | 757 |
758 if __name__ == "__main__": | 758 if __name__ == "__main__": |
759 sys.exit(TryChange(None, [], False)) | 759 sys.exit(TryChange(None, [], False)) |
OLD | NEW |