Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: trunk/tools/depot_tools/scm.py

Issue 146583013: Revert 250482 "Re-reland r245404 ("If the destination directory ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 IsGitSvn(checkout_root): 169 def IsGitSvn(cwd):
170 """Returns true if this repo looks like it's using git-svn.""" 170 """Returns true if this repo looks like it's using git-svn."""
171 # A git-svn checkout has a .git directory.
172 if not os.path.isdir(os.path.join(checkout_root, '.git')):
173 return False
174 # If you have any "svn-remote.*" config keys, we think you're using svn. 171 # If you have any "svn-remote.*" config keys, we think you're using svn.
175 try: 172 try:
176 GIT.Capture(['config', '--local', '--get-regexp', r'^svn-remote\.'], 173 GIT.Capture(['config', '--local', '--get-regexp', r'^svn-remote\.'],
177 cwd=checkout_root) 174 cwd=cwd)
178 return True 175 return True
179 except subprocess2.CalledProcessError: 176 except subprocess2.CalledProcessError:
180 return False 177 return False
181 178
182 @staticmethod 179 @staticmethod
183 def MatchSvnGlob(url, base_url, glob_spec, allow_wildcards): 180 def MatchSvnGlob(url, base_url, glob_spec, allow_wildcards):
184 """Return the corresponding git ref if |base_url| together with |glob_spec| 181 """Return the corresponding git ref if |base_url| together with |glob_spec|
185 matches the full |url|. 182 matches the full |url|.
186 183
187 If |allow_wildcards| is true, |glob_spec| can contain wildcards (see below). 184 If |allow_wildcards| is true, |glob_spec| can contain wildcards (see below).
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 401
405 @staticmethod 402 @staticmethod
406 def ParseGitSvnSha1(output): 403 def ParseGitSvnSha1(output):
407 """Parses git-svn output for the first sha1.""" 404 """Parses git-svn output for the first sha1."""
408 match = re.search(r'[0-9a-fA-F]{40}', output) 405 match = re.search(r'[0-9a-fA-F]{40}', output)
409 return match.group(0) if match else None 406 return match.group(0) if match else None
410 407
411 @staticmethod 408 @staticmethod
412 def GetSha1ForSvnRev(cwd, rev): 409 def GetSha1ForSvnRev(cwd, rev):
413 """Returns a corresponding git sha1 for a SVN revision.""" 410 """Returns a corresponding git sha1 for a SVN revision."""
414 if not GIT.IsGitSvn(cwd): 411 if not GIT.IsGitSvn(cwd=cwd):
415 return None 412 return None
416 try: 413 try:
417 output = GIT.Capture(['svn', 'find-rev', 'r' + str(rev)], cwd=cwd) 414 output = GIT.Capture(['svn', 'find-rev', 'r' + str(rev)], cwd=cwd)
418 return GIT.ParseGitSvnSha1(output) 415 return GIT.ParseGitSvnSha1(output)
419 except subprocess2.CalledProcessError: 416 except subprocess2.CalledProcessError:
420 return None 417 return None
421 418
422 @staticmethod 419 @staticmethod
423 def GetBlessedSha1ForSvnRev(cwd, rev): 420 def GetBlessedSha1ForSvnRev(cwd, rev):
424 """Returns a git commit hash from the master branch history that has 421 """Returns a git commit hash from the master branch history that has
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 # revert, like for properties. 1107 # revert, like for properties.
1111 if not os.path.isdir(cwd): 1108 if not os.path.isdir(cwd):
1112 # '.' was deleted. It's not worth continuing. 1109 # '.' was deleted. It's not worth continuing.
1113 return 1110 return
1114 try: 1111 try:
1115 SVN.Capture(['revert', file_status[1]], cwd=cwd) 1112 SVN.Capture(['revert', file_status[1]], cwd=cwd)
1116 except subprocess2.CalledProcessError: 1113 except subprocess2.CalledProcessError:
1117 if not os.path.exists(file_path): 1114 if not os.path.exists(file_path):
1118 continue 1115 continue
1119 raise 1116 raise
OLDNEW
« no previous file with comments | « trunk/tools/depot_tools/gclient_scm.py ('k') | trunk/tools/depot_tools/tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698