Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 return result | 67 return result |
| 68 | 68 |
| 69 | 69 |
| 70 def determine_scm(root): | 70 def determine_scm(root): |
| 71 """Similar to upload.py's version but much simpler. | 71 """Similar to upload.py's version but much simpler. |
| 72 | 72 |
| 73 Returns 'svn', 'git' or None. | 73 Returns 'svn', 'git' or None. |
| 74 """ | 74 """ |
| 75 if os.path.isdir(os.path.join(root, '.svn')): | 75 if os.path.isdir(os.path.join(root, '.svn')): |
| 76 return 'svn' | 76 return 'svn' |
| 77 elif os.path.isdir(os.path.join(root, '.svn')): | 77 elif os.path.isdir(os.path.join(root, '.git')): |
| 78 return 'git' | 78 return 'git' |
| 79 else: | 79 else: |
| 80 if (0 == subprocess.call( | 80 try: |
| 81 subprocess2.check_output( | |
|
Dirk Pranke
2011/04/05 21:01:29
I wonder if it makes sense to have another method
| |
| 81 ['git', 'rev-parse', '--show-cdup'], | 82 ['git', 'rev-parse', '--show-cdup'], |
| 82 stdout=subprocess.PIPE, cwd=root)): | 83 stdout=subprocess2.VOID, |
| 84 cwd=root) | |
| 83 return 'git' | 85 return 'git' |
| 84 else: | 86 except (OSError, subprocess2.CalledProcessError): |
| 85 return None | 87 return None |
| 86 | 88 |
| 87 | 89 |
| 88 class GIT(object): | 90 class GIT(object): |
| 89 @staticmethod | 91 @staticmethod |
| 90 def Capture(args, **kwargs): | 92 def Capture(args, **kwargs): |
| 91 return gclient_utils.CheckCall(['git'] + args, print_error=False, | 93 return gclient_utils.CheckCall(['git'] + args, print_error=False, |
| 92 **kwargs)[0] | 94 **kwargs)[0] |
| 93 | 95 |
| 94 @staticmethod | 96 @staticmethod |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 980 if (file_status[0][0] in ('D', 'A', '!') or | 982 if (file_status[0][0] in ('D', 'A', '!') or |
| 981 not file_status[0][1:].isspace()): | 983 not file_status[0][1:].isspace()): |
| 982 # Added, deleted file requires manual intervention and require calling | 984 # Added, deleted file requires manual intervention and require calling |
| 983 # revert, like for properties. | 985 # revert, like for properties. |
| 984 try: | 986 try: |
| 985 SVN.Capture(['revert', file_status[1]], cwd=repo_root) | 987 SVN.Capture(['revert', file_status[1]], cwd=repo_root) |
| 986 except gclient_utils.CheckCallError: | 988 except gclient_utils.CheckCallError: |
| 987 if not os.path.exists(file_path): | 989 if not os.path.exists(file_path): |
| 988 continue | 990 continue |
| 989 raise | 991 raise |
| OLD | NEW |