| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 def GetBranchRef(cwd): | 159 def GetBranchRef(cwd): |
| 160 """Returns the full branch reference, e.g. 'refs/heads/master'.""" | 160 """Returns the full branch reference, e.g. 'refs/heads/master'.""" |
| 161 return GIT.Capture(['symbolic-ref', 'HEAD'], cwd=cwd) | 161 return GIT.Capture(['symbolic-ref', 'HEAD'], cwd=cwd) |
| 162 | 162 |
| 163 @staticmethod | 163 @staticmethod |
| 164 def GetBranch(cwd): | 164 def GetBranch(cwd): |
| 165 """Returns the short branch name, e.g. 'master'.""" | 165 """Returns the short branch name, e.g. 'master'.""" |
| 166 return GIT.ShortBranchName(GIT.GetBranchRef(cwd)) | 166 return GIT.ShortBranchName(GIT.GetBranchRef(cwd)) |
| 167 | 167 |
| 168 @staticmethod | 168 @staticmethod |
| 169 def IsGit(cwd): |
| 170 """Returns True if this repo looks like it's using git.""" |
| 171 if os.path.exists(os.path.join(cwd, '.git')): |
| 172 return True |
| 173 if os.path.isdir(os.path.join(cwd, '.svn')): |
| 174 return False |
| 175 try: |
| 176 GIT.Capture(['config', '--local', '--list'], cwd=cwd) |
| 177 return True |
| 178 except subprocess2.CalledProcessError: |
| 179 return False |
| 180 |
| 181 @staticmethod |
| 169 def IsGitSvn(cwd): | 182 def IsGitSvn(cwd): |
| 170 """Returns true if this repo looks like it's using git-svn.""" | 183 """Returns True if this repo looks like it's using git-svn.""" |
| 171 # If you have any "svn-remote.*" config keys, we think you're using svn. | 184 # If you have any "svn-remote.*" config keys, we think you're using svn. |
| 172 try: | 185 try: |
| 173 GIT.Capture(['config', '--local', '--get-regexp', r'^svn-remote\.'], | 186 GIT.Capture(['config', '--local', '--get-regexp', r'^svn-remote\.'], |
| 174 cwd=cwd) | 187 cwd=cwd) |
| 175 return True | 188 return True |
| 176 except subprocess2.CalledProcessError: | 189 except subprocess2.CalledProcessError: |
| 177 return False | 190 return False |
| 178 | 191 |
| 179 @staticmethod | 192 @staticmethod |
| 180 def MatchSvnGlob(url, base_url, glob_spec, allow_wildcards): | 193 def MatchSvnGlob(url, base_url, glob_spec, allow_wildcards): |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 # revert, like for properties. | 1120 # revert, like for properties. |
| 1108 if not os.path.isdir(cwd): | 1121 if not os.path.isdir(cwd): |
| 1109 # '.' was deleted. It's not worth continuing. | 1122 # '.' was deleted. It's not worth continuing. |
| 1110 return | 1123 return |
| 1111 try: | 1124 try: |
| 1112 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1125 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
| 1113 except subprocess2.CalledProcessError: | 1126 except subprocess2.CalledProcessError: |
| 1114 if not os.path.exists(file_path): | 1127 if not os.path.exists(file_path): |
| 1115 continue | 1128 continue |
| 1116 raise | 1129 raise |
| OLD | NEW |