| 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 glob | 7 import glob |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import shutil | 10 import shutil |
| 11 import subprocess | 11 import subprocess |
| 12 import sys | 12 import sys |
| 13 import tempfile | 13 import tempfile |
| 14 import time |
| 14 import xml.dom.minidom | 15 import xml.dom.minidom |
| 15 | 16 |
| 16 import gclient_utils | 17 import gclient_utils |
| 17 | 18 |
| 18 def ValidateEmail(email): | 19 def ValidateEmail(email): |
| 19 return (re.match(r"^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", email) | 20 return (re.match(r"^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", email) |
| 20 is not None) | 21 is not None) |
| 21 | 22 |
| 22 | 23 |
| 23 def GetCasedPath(path): | 24 def GetCasedPath(path): |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 # else, which is good. Note that the patterns are only effective when | 375 # else, which is good. Note that the patterns are only effective when |
| 375 # these commands are used in their ordinary forms, the patterns are invalid | 376 # these commands are used in their ordinary forms, the patterns are invalid |
| 376 # for "svn status --show-updates", for example. | 377 # for "svn status --show-updates", for example. |
| 377 pattern = { | 378 pattern = { |
| 378 'checkout': update_pattern, | 379 'checkout': update_pattern, |
| 379 'status': status_pattern, | 380 'status': status_pattern, |
| 380 'update': update_pattern, | 381 'update': update_pattern, |
| 381 }[args[0]] | 382 }[args[0]] |
| 382 compiled_pattern = re.compile(pattern) | 383 compiled_pattern = re.compile(pattern) |
| 383 # Place an upper limit. | 384 # Place an upper limit. |
| 384 for _ in range(1, 10): | 385 for _ in range(10): |
| 385 previous_list_len = len(file_list) | 386 previous_list_len = len(file_list) |
| 386 failure = [] | 387 failure = [] |
| 387 | 388 |
| 388 def CaptureMatchingLines(line): | 389 def CaptureMatchingLines(line): |
| 389 match = compiled_pattern.search(line) | 390 match = compiled_pattern.search(line) |
| 390 if match: | 391 if match: |
| 391 file_list.append(match.group(1)) | 392 file_list.append(match.group(1)) |
| 392 if line.startswith('svn: '): | 393 if line.startswith('svn: '): |
| 393 failure.append(line) | 394 failure.append(line) |
| 394 | 395 |
| 395 try: | 396 try: |
| 396 SVN.RunAndFilterOutput(args, | 397 SVN.RunAndFilterOutput(args, |
| 397 in_directory, | 398 in_directory, |
| 398 options.verbose, | 399 options.verbose, |
| 399 True, | 400 True, |
| 400 CaptureMatchingLines) | 401 CaptureMatchingLines) |
| 401 except gclient_utils.Error: | 402 except gclient_utils.Error: |
| 402 # We enforce that some progress has been made or HTTP 502. | 403 # We enforce that some progress has been made or HTTP 502. |
| 403 if (filter(lambda x: '502 Bad Gateway' in x, failure) or | 404 if (filter(lambda x: '502 Bad Gateway' in x, failure) or |
| 404 (len(failure) and len(file_list) > previous_list_len)): | 405 (len(failure) and len(file_list) > previous_list_len)): |
| 405 if args[0] == 'checkout': | 406 if args[0] == 'checkout': |
| 406 # An aborted checkout is now an update. | 407 # An aborted checkout is now an update. |
| 407 args = ['update'] + args[1:] | 408 args = ['update'] + args[1:] |
| 409 print "Sleeping 15 seconds and retrying...." |
| 410 time.sleep(15) |
| 408 continue | 411 continue |
| 409 # No progress was made or an unknown error we aren't sure, bail out. | 412 # No progress was made or an unknown error we aren't sure, bail out. |
| 410 raise | 413 raise |
| 411 break | 414 break |
| 412 | 415 |
| 413 @staticmethod | 416 @staticmethod |
| 414 def RunAndFilterOutput(args, | 417 def RunAndFilterOutput(args, |
| 415 in_directory, | 418 in_directory, |
| 416 print_messages, | 419 print_messages, |
| 417 print_stdout, | 420 print_stdout, |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 if not SVN.current_version: | 781 if not SVN.current_version: |
| 779 SVN.current_version = SVN.Capture(['--version']).split()[2] | 782 SVN.current_version = SVN.Capture(['--version']).split()[2] |
| 780 current_version_list = map(only_int, SVN.current_version.split('.')) | 783 current_version_list = map(only_int, SVN.current_version.split('.')) |
| 781 for min_ver in map(int, min_version.split('.')): | 784 for min_ver in map(int, min_version.split('.')): |
| 782 ver = current_version_list.pop(0) | 785 ver = current_version_list.pop(0) |
| 783 if ver < min_ver: | 786 if ver < min_ver: |
| 784 return (False, SVN.current_version) | 787 return (False, SVN.current_version) |
| 785 elif ver > min_ver: | 788 elif ver > min_ver: |
| 786 return (True, SVN.current_version) | 789 return (True, SVN.current_version) |
| 787 return (True, SVN.current_version) | 790 return (True, SVN.current_version) |
| OLD | NEW |