OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 """ | 72 """ |
73 if os.path.isdir(os.path.join(root, '.svn')): | 73 if os.path.isdir(os.path.join(root, '.svn')): |
74 return 'svn' | 74 return 'svn' |
75 elif os.path.isdir(os.path.join(root, '.git')): | 75 elif os.path.isdir(os.path.join(root, '.git')): |
76 return 'git' | 76 return 'git' |
77 else: | 77 else: |
78 try: | 78 try: |
79 subprocess2.check_output( | 79 subprocess2.check_output( |
80 ['git', 'rev-parse', '--show-cdup'], | 80 ['git', 'rev-parse', '--show-cdup'], |
81 stdout=subprocess2.VOID, | 81 stdout=subprocess2.VOID, |
| 82 stderr=subprocess2.VOID, |
82 cwd=root) | 83 cwd=root) |
83 return 'git' | 84 return 'git' |
84 except (OSError, subprocess2.CalledProcessError): | 85 except (OSError, subprocess2.CalledProcessError): |
85 return None | 86 return None |
86 | 87 |
87 | 88 |
88 class GIT(object): | 89 class GIT(object): |
89 @staticmethod | 90 @staticmethod |
90 def Capture(args, **kwargs): | 91 def Capture(args, **kwargs): |
91 return subprocess2.check_output( | 92 return subprocess2.check_output( |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 if (file_status[0][0] in ('D', 'A', '!') or | 983 if (file_status[0][0] in ('D', 'A', '!') or |
983 not file_status[0][1:].isspace()): | 984 not file_status[0][1:].isspace()): |
984 # Added, deleted file requires manual intervention and require calling | 985 # Added, deleted file requires manual intervention and require calling |
985 # revert, like for properties. | 986 # revert, like for properties. |
986 try: | 987 try: |
987 SVN.Capture(['revert', file_status[1]], cwd=repo_root) | 988 SVN.Capture(['revert', file_status[1]], cwd=repo_root) |
988 except subprocess2.CalledProcessError: | 989 except subprocess2.CalledProcessError: |
989 if not os.path.exists(file_path): | 990 if not os.path.exists(file_path): |
990 continue | 991 continue |
991 raise | 992 raise |
OLD | NEW |