| 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 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 ver = current_version_list.pop(0) | 286 ver = current_version_list.pop(0) |
| 287 if ver < min_ver: | 287 if ver < min_ver: |
| 288 return (False, current_version) | 288 return (False, current_version) |
| 289 elif ver > min_ver: | 289 elif ver > min_ver: |
| 290 return (True, current_version) | 290 return (True, current_version) |
| 291 return (True, current_version) | 291 return (True, current_version) |
| 292 | 292 |
| 293 | 293 |
| 294 class SVN(object): | 294 class SVN(object): |
| 295 COMMAND = "svn" | 295 COMMAND = "svn" |
| 296 current_version = None |
| 296 | 297 |
| 297 @staticmethod | 298 @staticmethod |
| 298 def Run(args, in_directory): | 299 def Run(args, in_directory): |
| 299 """Runs svn, sending output to stdout. | 300 """Runs svn, sending output to stdout. |
| 300 | 301 |
| 301 Args: | 302 Args: |
| 302 args: A sequence of command line parameters to be passed to svn. | 303 args: A sequence of command line parameters to be passed to svn. |
| 303 in_directory: The directory where svn is to be run. | 304 in_directory: The directory where svn is to be run. |
| 304 | 305 |
| 305 Raises: | 306 Raises: |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 if not cur_dir_repo_root: | 759 if not cur_dir_repo_root: |
| 759 return None | 760 return None |
| 760 | 761 |
| 761 while True: | 762 while True: |
| 762 parent = os.path.dirname(directory) | 763 parent = os.path.dirname(directory) |
| 763 if (SVN.CaptureInfo(parent, print_error=False).get( | 764 if (SVN.CaptureInfo(parent, print_error=False).get( |
| 764 "Repository Root") != cur_dir_repo_root): | 765 "Repository Root") != cur_dir_repo_root): |
| 765 break | 766 break |
| 766 directory = parent | 767 directory = parent |
| 767 return GetCasedPath(directory) | 768 return GetCasedPath(directory) |
| 769 |
| 770 @staticmethod |
| 771 def AssertVersion(min_version): |
| 772 """Asserts svn's version is at least min_version.""" |
| 773 def only_int(val): |
| 774 if val.isdigit(): |
| 775 return int(val) |
| 776 else: |
| 777 return 0 |
| 778 if not SVN.current_version: |
| 779 SVN.current_version = SVN.Capture(['--version']).split()[2] |
| 780 current_version_list = map(only_int, SVN.current_version.split('.')) |
| 781 for min_ver in map(int, min_version.split('.')): |
| 782 ver = current_version_list.pop(0) |
| 783 if ver < min_ver: |
| 784 return (False, SVN.current_version) |
| 785 elif ver > min_ver: |
| 786 return (True, SVN.current_version) |
| 787 return (True, SVN.current_version) |
| OLD | NEW |