OLD | NEW |
1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """SCM-specific utility classes.""" | 5 """SCM-specific utility classes.""" |
6 | 6 |
7 import cStringIO | 7 import cStringIO |
8 import glob | 8 import glob |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 if line.startswith('svn: '): | 439 if line.startswith('svn: '): |
440 failure.append(line) | 440 failure.append(line) |
441 | 441 |
442 try: | 442 try: |
443 SVN.RunAndFilterOutput(args, | 443 SVN.RunAndFilterOutput(args, |
444 in_directory, | 444 in_directory, |
445 options.verbose, | 445 options.verbose, |
446 True, | 446 True, |
447 CaptureMatchingLines) | 447 CaptureMatchingLines) |
448 except gclient_utils.Error: | 448 except gclient_utils.Error: |
449 # We enforce that some progress has been made or HTTP 502. | 449 # Subversion client is really misbehaving with Google Code. |
450 if (filter(lambda x: '502 Bad Gateway' in x, failure) or | 450 if args[0] == 'checkout': |
451 (len(failure) and len(file_list) > previous_list_len)): | 451 # Ensure at least one file was checked out, otherwise *delete* the |
452 if args[0] == 'checkout': | 452 # directory. |
453 # An aborted checkout is now an update. | 453 if len(file_list) == previous_list_len: |
| 454 for x in failure: |
| 455 if ('502 Bad Gateway' in x or |
| 456 'svn: REPORT of \'/svn/!svn/vcc/default\': 200 OK' in x): |
| 457 # No file were checked out, so make sure the directory is |
| 458 # deleted in case it's messed up and try again. |
| 459 # Warning: It's bad, it assumes args[2] is the directory |
| 460 # argument. |
| 461 if os.path.isdir(args[2]): |
| 462 chromium_utils.RemoveDirectory(args[2]) |
| 463 break |
| 464 else: |
| 465 # No known svn error was found, bail out. |
| 466 raise |
| 467 else: |
| 468 # Progress was made, convert to update since an aborted checkout |
| 469 # is now an update. |
454 args = ['update'] + args[1:] | 470 args = ['update'] + args[1:] |
455 print "Sleeping 15 seconds and retrying...." | 471 else: |
456 time.sleep(15) | 472 # It was an update or export. |
457 continue | 473 # We enforce that some progress has been made or HTTP 502. |
458 # No progress was made or an unknown error we aren't sure, bail out. | 474 if len(file_list) == previous_list_len: |
459 raise | 475 for x in failure: |
| 476 if ('502 Bad Gateway' in x or |
| 477 'svn: REPORT of \'/svn/!svn/vcc/default\': 200 OK' in x): |
| 478 # Ok, know failure code. |
| 479 break |
| 480 else: |
| 481 # No known svn error was found, bail out. |
| 482 raise |
| 483 else: |
| 484 # Progress was made, it's fine. |
| 485 pass |
| 486 print "Sleeping 15 seconds and retrying...." |
| 487 time.sleep(15) |
| 488 continue |
460 break | 489 break |
461 | 490 |
462 @staticmethod | 491 @staticmethod |
463 def RunAndFilterOutput(args, | 492 def RunAndFilterOutput(args, |
464 in_directory, | 493 in_directory, |
465 print_messages, | 494 print_messages, |
466 print_stdout, | 495 print_stdout, |
467 filter_fn): | 496 filter_fn): |
468 """Runs a command, optionally outputting to stdout. | 497 """Runs a command, optionally outputting to stdout. |
469 | 498 |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 if not SVN.current_version: | 915 if not SVN.current_version: |
887 SVN.current_version = SVN.Capture(['--version']).split()[2] | 916 SVN.current_version = SVN.Capture(['--version']).split()[2] |
888 current_version_list = map(only_int, SVN.current_version.split('.')) | 917 current_version_list = map(only_int, SVN.current_version.split('.')) |
889 for min_ver in map(int, min_version.split('.')): | 918 for min_ver in map(int, min_version.split('.')): |
890 ver = current_version_list.pop(0) | 919 ver = current_version_list.pop(0) |
891 if ver < min_ver: | 920 if ver < min_ver: |
892 return (False, SVN.current_version) | 921 return (False, SVN.current_version) |
893 elif ver > min_ver: | 922 elif ver > min_ver: |
894 return (True, SVN.current_version) | 923 return (True, SVN.current_version) |
895 return (True, SVN.current_version) | 924 return (True, SVN.current_version) |
OLD | NEW |