| 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 os | 7 import os |
| 8 import re | 8 import re |
| 9 import shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 pattern = { | 326 pattern = { |
| 327 'checkout': update_pattern, | 327 'checkout': update_pattern, |
| 328 'status': status_pattern, | 328 'status': status_pattern, |
| 329 'update': update_pattern, | 329 'update': update_pattern, |
| 330 }[args[0]] | 330 }[args[0]] |
| 331 compiled_pattern = re.compile(pattern) | 331 compiled_pattern = re.compile(pattern) |
| 332 # Place an upper limit. | 332 # Place an upper limit. |
| 333 for i in range(1, 10): | 333 for i in range(1, 10): |
| 334 previous_list_len = len(file_list) | 334 previous_list_len = len(file_list) |
| 335 failure = [] | 335 failure = [] |
| 336 |
| 336 def CaptureMatchingLines(line): | 337 def CaptureMatchingLines(line): |
| 337 match = compiled_pattern.search(line) | 338 match = compiled_pattern.search(line) |
| 338 if match: | 339 if match: |
| 339 file_list.append(match.group(1)) | 340 file_list.append(match.group(1)) |
| 340 if line.startswith('svn: '): | 341 if line.startswith('svn: '): |
| 341 # We can't raise an exception. We can't alias a variable. Use a cheap | 342 # We can't raise an exception. We can't alias a variable. Use a cheap |
| 342 # way. | 343 # way. |
| 343 failure.append(True) | 344 failure.append(True) |
| 345 |
| 344 try: | 346 try: |
| 345 SVN.RunAndFilterOutput(args, | 347 SVN.RunAndFilterOutput(args, |
| 346 in_directory, | 348 in_directory, |
| 347 options.verbose, | 349 options.verbose, |
| 348 True, | 350 True, |
| 349 CaptureMatchingLines) | 351 CaptureMatchingLines) |
| 350 except gclient_utils.Error: | 352 except gclient_utils.Error: |
| 351 # We enforce that some progress has been made. | 353 # We enforce that some progress has been made. |
| 352 if len(failure) and len(file_list) > previous_list_len: | 354 if len(failure) and len(file_list) > previous_list_len: |
| 353 if args[0] == 'checkout': | 355 if args[0] == 'checkout': |
| 354 args = args[:] | 356 args = args[:] |
| 355 # An aborted checkout is now an update. | 357 # An aborted checkout is now an update. |
| 356 args[0] = 'update' | 358 args[0] = 'update' |
| 357 continue | 359 continue |
| 360 # No progress was made, bail out. |
| 361 raise |
| 358 break | 362 break |
| 359 | 363 |
| 360 @staticmethod | 364 @staticmethod |
| 361 def RunAndFilterOutput(args, | 365 def RunAndFilterOutput(args, |
| 362 in_directory, | 366 in_directory, |
| 363 print_messages, | 367 print_messages, |
| 364 print_stdout, | 368 print_stdout, |
| 365 filter): | 369 filter): |
| 366 """Runs a command, optionally outputting to stdout. | 370 """Runs a command, optionally outputting to stdout. |
| 367 | 371 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 if not cur_dir_repo_root: | 701 if not cur_dir_repo_root: |
| 698 return None | 702 return None |
| 699 | 703 |
| 700 while True: | 704 while True: |
| 701 parent = os.path.dirname(directory) | 705 parent = os.path.dirname(directory) |
| 702 if (SVN.CaptureInfo(parent, print_error=False).get( | 706 if (SVN.CaptureInfo(parent, print_error=False).get( |
| 703 "Repository Root") != cur_dir_repo_root): | 707 "Repository Root") != cur_dir_repo_root): |
| 704 break | 708 break |
| 705 directory = parent | 709 directory = parent |
| 706 return directory | 710 return directory |
| OLD | NEW |