| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 return int(val) | 91 return int(val) |
| 92 else: | 92 else: |
| 93 return 0 | 93 return 0 |
| 94 | 94 |
| 95 | 95 |
| 96 class GIT(object): | 96 class GIT(object): |
| 97 current_version = None | 97 current_version = None |
| 98 | 98 |
| 99 @staticmethod | 99 @staticmethod |
| 100 def Capture(args, cwd, **kwargs): | 100 def Capture(args, cwd, **kwargs): |
| 101 env = os.environ.copy() |
| 102 # 'cat' is a magical git string that disables pagers on all platforms. |
| 103 env['GIT_PAGER'] = 'cat' |
| 101 return subprocess2.check_output( | 104 return subprocess2.check_output( |
| 102 ['git', '--no-pager'] + args, | 105 ['git'] + args, |
| 103 cwd=cwd, stderr=subprocess2.PIPE, **kwargs).strip() | 106 cwd=cwd, stderr=subprocess2.PIPE, env=env, **kwargs).strip() |
| 104 | 107 |
| 105 @staticmethod | 108 @staticmethod |
| 106 def CaptureStatus(files, cwd, upstream_branch): | 109 def CaptureStatus(files, cwd, upstream_branch): |
| 107 """Returns git status. | 110 """Returns git status. |
| 108 | 111 |
| 109 @files can be a string (one file) or a list of files. | 112 @files can be a string (one file) or a list of files. |
| 110 | 113 |
| 111 Returns an array of (status, file) tuples.""" | 114 Returns an array of (status, file) tuples.""" |
| 112 if upstream_branch is None: | 115 if upstream_branch is None: |
| 113 upstream_branch = GIT.GetUpstreamBranch(cwd) | 116 upstream_branch = GIT.GetUpstreamBranch(cwd) |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 # revert, like for properties. | 1106 # revert, like for properties. |
| 1104 if not os.path.isdir(cwd): | 1107 if not os.path.isdir(cwd): |
| 1105 # '.' was deleted. It's not worth continuing. | 1108 # '.' was deleted. It's not worth continuing. |
| 1106 return | 1109 return |
| 1107 try: | 1110 try: |
| 1108 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1111 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
| 1109 except subprocess2.CalledProcessError: | 1112 except subprocess2.CalledProcessError: |
| 1110 if not os.path.exists(file_path): | 1113 if not os.path.exists(file_path): |
| 1111 continue | 1114 continue |
| 1112 raise | 1115 raise |
| OLD | NEW |