OLD | NEW |
1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 |
11 import shutil | 11 import shutil |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 # these commands are used in their ordinary forms, the patterns are invalid | 344 # these commands are used in their ordinary forms, the patterns are invalid |
345 # for "svn status --show-updates", for example. | 345 # for "svn status --show-updates", for example. |
346 pattern = { | 346 pattern = { |
347 'checkout': update_pattern, | 347 'checkout': update_pattern, |
348 'status': status_pattern, | 348 'status': status_pattern, |
349 'update': update_pattern, | 349 'update': update_pattern, |
350 }[args[0]] | 350 }[args[0]] |
351 compiled_pattern = re.compile(pattern) | 351 compiled_pattern = re.compile(pattern) |
352 # Place an upper limit. | 352 # Place an upper limit. |
353 backoff_time = 5 | 353 backoff_time = 5 |
354 i = 0 | 354 retries = 0 |
355 while True: | 355 while True: |
356 i += 1 | 356 retries += 1 |
357 previous_list_len = len(file_list) | 357 previous_list_len = len(file_list) |
358 failure = [] | 358 failure = [] |
359 | 359 |
360 def CaptureMatchingLines(line): | 360 def CaptureMatchingLines(line): |
361 match = compiled_pattern.search(line) | 361 match = compiled_pattern.search(line) |
362 if match: | 362 if match: |
363 file_list.append(match.group(1)) | 363 file_list.append(match.group(1)) |
364 if line.startswith('svn: '): | 364 if line.startswith('svn: '): |
365 failure.append(line) | 365 failure.append(line) |
366 | 366 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 else: | 399 else: |
400 # Progress was made, convert to update since an aborted checkout | 400 # Progress was made, convert to update since an aborted checkout |
401 # is now an update. | 401 # is now an update. |
402 args = ['update'] + args[1:] | 402 args = ['update'] + args[1:] |
403 else: | 403 else: |
404 # It was an update or export. | 404 # It was an update or export. |
405 # We enforce that some progress has been made or a known failure. | 405 # We enforce that some progress has been made or a known failure. |
406 if len(file_list) == previous_list_len and not IsKnownFailure(): | 406 if len(file_list) == previous_list_len and not IsKnownFailure(): |
407 # No known svn error was found and no progress, bail out. | 407 # No known svn error was found and no progress, bail out. |
408 raise | 408 raise |
409 if i == 10: | 409 if retries == 10: |
410 raise | 410 raise |
411 print "Sleeping %.1f seconds and retrying...." % backoff_time | 411 print "Sleeping %.1f seconds and retrying...." % backoff_time |
412 time.sleep(backoff_time) | 412 time.sleep(backoff_time) |
413 backoff_time *= 1.3 | 413 backoff_time *= 1.3 |
414 continue | 414 continue |
415 break | 415 break |
416 | 416 |
417 @staticmethod | 417 @staticmethod |
418 def CaptureInfo(cwd): | 418 def CaptureInfo(cwd): |
419 """Returns a dictionary from the svn info output for the given file. | 419 """Returns a dictionary from the svn info output for the given file. |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 if not SVN.current_version: | 821 if not SVN.current_version: |
822 SVN.current_version = SVN.Capture(['--version']).split()[2] | 822 SVN.current_version = SVN.Capture(['--version']).split()[2] |
823 current_version_list = map(only_int, SVN.current_version.split('.')) | 823 current_version_list = map(only_int, SVN.current_version.split('.')) |
824 for min_ver in map(int, min_version.split('.')): | 824 for min_ver in map(int, min_version.split('.')): |
825 ver = current_version_list.pop(0) | 825 ver = current_version_list.pop(0) |
826 if ver < min_ver: | 826 if ver < min_ver: |
827 return (False, SVN.current_version) | 827 return (False, SVN.current_version) |
828 elif ver > min_ver: | 828 elif ver > min_ver: |
829 return (True, SVN.current_version) | 829 return (True, SVN.current_version) |
830 return (True, SVN.current_version) | 830 return (True, SVN.current_version) |
OLD | NEW |