| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 cwd=root) | 82 cwd=root) |
| 83 return 'git' | 83 return 'git' |
| 84 except (OSError, subprocess2.CalledProcessError): | 84 except (OSError, subprocess2.CalledProcessError): |
| 85 return None | 85 return None |
| 86 | 86 |
| 87 | 87 |
| 88 class GIT(object): | 88 class GIT(object): |
| 89 @staticmethod | 89 @staticmethod |
| 90 def Capture(args, **kwargs): | 90 def Capture(args, **kwargs): |
| 91 return subprocess2.check_output( | 91 return subprocess2.check_output( |
| 92 ['git'] + args, stderr=subprocess2.VOID, **kwargs) | 92 ['git'] + args, stderr=subprocess2.PIPE, **kwargs) |
| 93 | 93 |
| 94 @staticmethod | 94 @staticmethod |
| 95 def CaptureStatus(files, upstream_branch=None): | 95 def CaptureStatus(files, upstream_branch=None): |
| 96 """Returns git status. | 96 """Returns git status. |
| 97 | 97 |
| 98 @files can be a string (one file) or a list of files. | 98 @files can be a string (one file) or a list of files. |
| 99 | 99 |
| 100 Returns an array of (status, file) tuples.""" | 100 Returns an array of (status, file) tuples.""" |
| 101 if upstream_branch is None: | 101 if upstream_branch is None: |
| 102 upstream_branch = GIT.GetUpstreamBranch(os.getcwd()) | 102 upstream_branch = GIT.GetUpstreamBranch(os.getcwd()) |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 if (file_status[0][0] in ('D', 'A', '!') or | 982 if (file_status[0][0] in ('D', 'A', '!') or |
| 983 not file_status[0][1:].isspace()): | 983 not file_status[0][1:].isspace()): |
| 984 # Added, deleted file requires manual intervention and require calling | 984 # Added, deleted file requires manual intervention and require calling |
| 985 # revert, like for properties. | 985 # revert, like for properties. |
| 986 try: | 986 try: |
| 987 SVN.Capture(['revert', file_status[1]], cwd=repo_root) | 987 SVN.Capture(['revert', file_status[1]], cwd=repo_root) |
| 988 except subprocess2.CalledProcessError: | 988 except subprocess2.CalledProcessError: |
| 989 if not os.path.exists(file_path): | 989 if not os.path.exists(file_path): |
| 990 continue | 990 continue |
| 991 raise | 991 raise |
| OLD | NEW |