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 | |
M-A Ruel
2013/07/08 19:10:50
same
| |
102 env['GIT_PAGER'] = 'cat' # Magical string that disables pagers. | |
101 return subprocess2.check_output( | 103 return subprocess2.check_output( |
102 ['git', '--no-pager'] + args, | 104 ['git'] + args, |
103 cwd=cwd, stderr=subprocess2.PIPE, **kwargs) | 105 cwd=cwd, stderr=subprocess2.PIPE, env=env, **kwargs) |
104 | 106 |
105 @staticmethod | 107 @staticmethod |
106 def CaptureStatus(files, cwd, upstream_branch): | 108 def CaptureStatus(files, cwd, upstream_branch): |
107 """Returns git status. | 109 """Returns git status. |
108 | 110 |
109 @files can be a string (one file) or a list of files. | 111 @files can be a string (one file) or a list of files. |
110 | 112 |
111 Returns an array of (status, file) tuples.""" | 113 Returns an array of (status, file) tuples.""" |
112 if upstream_branch is None: | 114 if upstream_branch is None: |
113 upstream_branch = GIT.GetUpstreamBranch(cwd) | 115 upstream_branch = GIT.GetUpstreamBranch(cwd) |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 # revert, like for properties. | 1092 # revert, like for properties. |
1091 if not os.path.isdir(cwd): | 1093 if not os.path.isdir(cwd): |
1092 # '.' was deleted. It's not worth continuing. | 1094 # '.' was deleted. It's not worth continuing. |
1093 return | 1095 return |
1094 try: | 1096 try: |
1095 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1097 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
1096 except subprocess2.CalledProcessError: | 1098 except subprocess2.CalledProcessError: |
1097 if not os.path.exists(file_path): | 1099 if not os.path.exists(file_path): |
1098 continue | 1100 continue |
1099 raise | 1101 raise |
OLD | NEW |