| 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 return os.path.abspath(GIT.Capture(['rev-parse', '--git-dir'], cwd=cwd)) | 436 return os.path.abspath(GIT.Capture(['rev-parse', '--git-dir'], cwd=cwd)) |
| 437 | 437 |
| 438 @staticmethod | 438 @staticmethod |
| 439 def IsInsideWorkTree(cwd): | 439 def IsInsideWorkTree(cwd): |
| 440 try: | 440 try: |
| 441 return GIT.Capture(['rev-parse', '--is-inside-work-tree'], cwd=cwd) | 441 return GIT.Capture(['rev-parse', '--is-inside-work-tree'], cwd=cwd) |
| 442 except (OSError, subprocess2.CalledProcessError): | 442 except (OSError, subprocess2.CalledProcessError): |
| 443 return False | 443 return False |
| 444 | 444 |
| 445 @staticmethod | 445 @staticmethod |
| 446 def IsDirectoryVersioned(cwd, relative_dir): | |
| 447 """Checks whether the given |relative_dir| is part of cwd's repo.""" | |
| 448 return bool(GIT.Capture(['ls-tree', 'HEAD', relative_dir], cwd=cwd)) | |
| 449 | |
| 450 @staticmethod | |
| 451 def CleanupDir(cwd, relative_dir): | |
| 452 """Cleans up untracked file inside |relative_dir|.""" | |
| 453 return bool(GIT.Capture(['clean', '-df', relative_dir], cwd=cwd)) | |
| 454 | |
| 455 @staticmethod | |
| 456 def GetGitSvnHeadRev(cwd): | 446 def GetGitSvnHeadRev(cwd): |
| 457 """Gets the most recently pulled git-svn revision.""" | 447 """Gets the most recently pulled git-svn revision.""" |
| 458 try: | 448 try: |
| 459 output = GIT.Capture(['svn', 'info'], cwd=cwd) | 449 output = GIT.Capture(['svn', 'info'], cwd=cwd) |
| 460 match = re.search(r'^Revision: ([0-9]+)$', output, re.MULTILINE) | 450 match = re.search(r'^Revision: ([0-9]+)$', output, re.MULTILINE) |
| 461 return int(match.group(1)) if match else None | 451 return int(match.group(1)) if match else None |
| 462 except (subprocess2.CalledProcessError, ValueError): | 452 except (subprocess2.CalledProcessError, ValueError): |
| 463 return None | 453 return None |
| 464 | 454 |
| 465 @staticmethod | 455 @staticmethod |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 # revert, like for properties. | 1160 # revert, like for properties. |
| 1171 if not os.path.isdir(cwd): | 1161 if not os.path.isdir(cwd): |
| 1172 # '.' was deleted. It's not worth continuing. | 1162 # '.' was deleted. It's not worth continuing. |
| 1173 return | 1163 return |
| 1174 try: | 1164 try: |
| 1175 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1165 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
| 1176 except subprocess2.CalledProcessError: | 1166 except subprocess2.CalledProcessError: |
| 1177 if not os.path.exists(file_path): | 1167 if not os.path.exists(file_path): |
| 1178 continue | 1168 continue |
| 1179 raise | 1169 raise |
| OLD | NEW |