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 verbose, | 445 verbose, |
446 True, | 446 True, |
447 CaptureMatchingLines) | 447 CaptureMatchingLines) |
448 except gclient_utils.Error: | 448 except gclient_utils.Error: |
| 449 def IsKnownFailure(): |
| 450 for x in failure: |
| 451 if (x.startswith('svn: OPTIONS of') or |
| 452 x.startswith('svn: PROPFIND of') or |
| 453 x.startswith('svn: REPORT of') or |
| 454 x.startswith('svn: Unknown hostname')): |
| 455 return True |
| 456 return False |
| 457 |
449 # Subversion client is really misbehaving with Google Code. | 458 # Subversion client is really misbehaving with Google Code. |
450 if args[0] == 'checkout': | 459 if args[0] == 'checkout': |
451 # Ensure at least one file was checked out, otherwise *delete* the | 460 # Ensure at least one file was checked out, otherwise *delete* the |
452 # directory. | 461 # directory. |
453 if len(file_list) == previous_list_len: | 462 if len(file_list) == previous_list_len: |
454 for x in failure: | 463 if not IsKnownFailure(): |
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 gclient_utils.RemoveDirectory(args[2]) | |
463 break | |
464 else: | |
465 # No known svn error was found, bail out. | 464 # No known svn error was found, bail out. |
466 raise | 465 raise |
| 466 # No file were checked out, so make sure the directory is |
| 467 # deleted in case it's messed up and try again. |
| 468 # Warning: It's bad, it assumes args[2] is the directory |
| 469 # argument. |
| 470 if os.path.isdir(args[2]): |
| 471 gclient_utils.RemoveDirectory(args[2]) |
467 else: | 472 else: |
468 # Progress was made, convert to update since an aborted checkout | 473 # Progress was made, convert to update since an aborted checkout |
469 # is now an update. | 474 # is now an update. |
470 args = ['update'] + args[1:] | 475 args = ['update'] + args[1:] |
471 else: | 476 else: |
472 # It was an update or export. | 477 # It was an update or export. |
473 # We enforce that some progress has been made or HTTP 502. | 478 # We enforce that some progress has been made or a known failure. |
474 if len(file_list) == previous_list_len: | 479 if len(file_list) == previous_list_len and not IsKnownFailure(): |
475 for x in failure: | 480 # No known svn error was found and no progress, bail out. |
476 if ('502 Bad Gateway' in x or | 481 raise |
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...." | 482 print "Sleeping 15 seconds and retrying...." |
487 time.sleep(15) | 483 time.sleep(15) |
488 continue | 484 continue |
489 break | 485 break |
490 | 486 |
491 @staticmethod | 487 @staticmethod |
492 def RunAndFilterOutput(args, | 488 def RunAndFilterOutput(args, |
493 in_directory, | 489 in_directory, |
494 print_messages, | 490 print_messages, |
495 print_stdout, | 491 print_stdout, |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 if not SVN.current_version: | 936 if not SVN.current_version: |
941 SVN.current_version = SVN.Capture(['--version']).split()[2] | 937 SVN.current_version = SVN.Capture(['--version']).split()[2] |
942 current_version_list = map(only_int, SVN.current_version.split('.')) | 938 current_version_list = map(only_int, SVN.current_version.split('.')) |
943 for min_ver in map(int, min_version.split('.')): | 939 for min_ver in map(int, min_version.split('.')): |
944 ver = current_version_list.pop(0) | 940 ver = current_version_list.pop(0) |
945 if ver < min_ver: | 941 if ver < min_ver: |
946 return (False, SVN.current_version) | 942 return (False, SVN.current_version) |
947 elif ver > min_ver: | 943 elif ver > min_ver: |
948 return (True, SVN.current_version) | 944 return (True, SVN.current_version) |
949 return (True, SVN.current_version) | 945 return (True, SVN.current_version) |
OLD | NEW |