| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 try: | 408 try: |
| 409 GIT.Capture(['rev-parse', rev], cwd=cwd) | 409 GIT.Capture(['rev-parse', rev], cwd=cwd) |
| 410 return True | 410 return True |
| 411 except subprocess2.CalledProcessError: | 411 except subprocess2.CalledProcessError: |
| 412 return False | 412 return False |
| 413 | 413 |
| 414 @classmethod | 414 @classmethod |
| 415 def AssertVersion(cls, min_version): | 415 def AssertVersion(cls, min_version): |
| 416 """Asserts git's version is at least min_version.""" | 416 """Asserts git's version is at least min_version.""" |
| 417 if cls.current_version is None: | 417 if cls.current_version is None: |
| 418 cls.current_version = cls.Capture(['--version'], '.').split()[-1] | 418 current_version = cls.Capture(['--version'], '.') |
| 419 matched = re.search(r'version ([0-9\.]+)', current_version) |
| 420 cls.current_version = matched.group(1) |
| 419 current_version_list = map(only_int, cls.current_version.split('.')) | 421 current_version_list = map(only_int, cls.current_version.split('.')) |
| 420 for min_ver in map(int, min_version.split('.')): | 422 for min_ver in map(int, min_version.split('.')): |
| 421 ver = current_version_list.pop(0) | 423 ver = current_version_list.pop(0) |
| 422 if ver < min_ver: | 424 if ver < min_ver: |
| 423 return (False, cls.current_version) | 425 return (False, cls.current_version) |
| 424 elif ver > min_ver: | 426 elif ver > min_ver: |
| 425 return (True, cls.current_version) | 427 return (True, cls.current_version) |
| 426 return (True, cls.current_version) | 428 return (True, cls.current_version) |
| 427 | 429 |
| 428 | 430 |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 # revert, like for properties. | 1050 # revert, like for properties. |
| 1049 if not os.path.isdir(cwd): | 1051 if not os.path.isdir(cwd): |
| 1050 # '.' was deleted. It's not worth continuing. | 1052 # '.' was deleted. It's not worth continuing. |
| 1051 return | 1053 return |
| 1052 try: | 1054 try: |
| 1053 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1055 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
| 1054 except subprocess2.CalledProcessError: | 1056 except subprocess2.CalledProcessError: |
| 1055 if not os.path.exists(file_path): | 1057 if not os.path.exists(file_path): |
| 1056 continue | 1058 continue |
| 1057 raise | 1059 raise |
| OLD | NEW |