Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: scm.py

Issue 4132002: Fix retry mechanism to raise when it fails to checkout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
jochen (gone - plz use gerrit) 2010/10/26 09:29:03 nit. non-std copyright header
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
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 for _ in range(10): 354 i = 0
jochen (gone - plz use gerrit) 2010/10/26 09:29:03 maybe use a more descriptive variable name, and si
355 while True:
356 i += 1
355 previous_list_len = len(file_list) 357 previous_list_len = len(file_list)
356 failure = [] 358 failure = []
357 359
358 def CaptureMatchingLines(line): 360 def CaptureMatchingLines(line):
359 match = compiled_pattern.search(line) 361 match = compiled_pattern.search(line)
360 if match: 362 if match:
361 file_list.append(match.group(1)) 363 file_list.append(match.group(1))
362 if line.startswith('svn: '): 364 if line.startswith('svn: '):
363 failure.append(line) 365 failure.append(line)
364 366
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 else: 399 else:
398 # Progress was made, convert to update since an aborted checkout 400 # Progress was made, convert to update since an aborted checkout
399 # is now an update. 401 # is now an update.
400 args = ['update'] + args[1:] 402 args = ['update'] + args[1:]
401 else: 403 else:
402 # It was an update or export. 404 # It was an update or export.
403 # 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.
404 if len(file_list) == previous_list_len and not IsKnownFailure(): 406 if len(file_list) == previous_list_len and not IsKnownFailure():
405 # No known svn error was found and no progress, bail out. 407 # No known svn error was found and no progress, bail out.
406 raise 408 raise
409 if i == 10:
410 raise
407 print "Sleeping %.1f seconds and retrying...." % backoff_time 411 print "Sleeping %.1f seconds and retrying...." % backoff_time
408 time.sleep(backoff_time) 412 time.sleep(backoff_time)
409 backoff_time *= 1.3 413 backoff_time *= 1.3
410 continue 414 continue
411 break 415 break
412 416
413 @staticmethod 417 @staticmethod
414 def CaptureInfo(cwd): 418 def CaptureInfo(cwd):
415 """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.
416 420
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 if not SVN.current_version: 821 if not SVN.current_version:
818 SVN.current_version = SVN.Capture(['--version']).split()[2] 822 SVN.current_version = SVN.Capture(['--version']).split()[2]
819 current_version_list = map(only_int, SVN.current_version.split('.')) 823 current_version_list = map(only_int, SVN.current_version.split('.'))
820 for min_ver in map(int, min_version.split('.')): 824 for min_ver in map(int, min_version.split('.')):
821 ver = current_version_list.pop(0) 825 ver = current_version_list.pop(0)
822 if ver < min_ver: 826 if ver < min_ver:
823 return (False, SVN.current_version) 827 return (False, SVN.current_version)
824 elif ver > min_ver: 828 elif ver > min_ver:
825 return (True, SVN.current_version) 829 return (True, SVN.current_version)
826 return (True, SVN.current_version) 830 return (True, SVN.current_version)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698