Commit 312a6a4e authored by szager@google.com's avatar szager@google.com

Fix safesync_url handling for git.

Takes into account the new submodule-enabled repository layout.
Review URL: https://codereview.chromium.org/11098064

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@161403 0039d316-1c4b-4281-b951-d872f2087c98
parent 1d23a428
......@@ -589,7 +589,14 @@ class GitWrapper(SCMWrapper):
if options.verbose:
print('Running git svn fetch. This might take a while.\n')
scm.GIT.Capture(['svn', 'fetch'], cwd=self.checkout_path)
sha1 = scm.GIT.GetSha1ForSvnRev(cwd=self.checkout_path, rev=rev)
try:
sha1 = scm.GIT.GetSha1ForSvnRev(cwd=self.checkout_path, rev=rev)
except gclient_utils.Error, e:
sha1 = e.message
print('\nWarning: Could not find a git revision with accurate\n'
'.DEPS.git that maps to SVN revision %s. Sync-ing to\n'
'the closest sane git revision, which is:\n'
' %s\n' % (rev, e.message))
if not sha1:
raise gclient_utils.Error(
( 'It appears that either your git-svn remote is incorrectly\n'
......
......@@ -402,8 +402,23 @@ class GIT(object):
if not GIT.IsGitSvn(cwd=cwd):
return None
try:
output = GIT.Capture(['svn', 'find-rev', 'r' + str(rev)], cwd=cwd)
return GIT.ParseGitSvnSha1(output)
git_svn_rev = GIT.Capture(
['svn', 'find-rev', 'r' + str(rev)], cwd=cwd).rstrip()
if not git_svn_rev:
return None
output = GIT.Capture(
['rev-list', '--ancestry-path', '--reverse',
'--grep', 'SVN changes up to revision [0-9]*',
'%s..refs/remotes/origin/master' % git_svn_rev], cwd=cwd)
if not output:
return None
sha1 = output.splitlines()[0]
if not sha1:
return None
output = GIT.Capture(['rev-list', '-n', '1', '%s^1' % sha1], cwd=cwd)
if git_svn_rev != output.rstrip():
raise gclient_utils.Error(sha1)
return sha1
except subprocess2.CalledProcessError:
return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment