Commit 3830a67f authored by iannucci@chromium.org's avatar iannucci@chromium.org

Make safesync w/ git hash work when lkgr is ahead of clone.


R=maruel@chromium.org, szager@chromium.org
BUG=


Review URL: https://chromiumcodereview.appspot.com/12301002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@183275 0039d316-1c4b-4281-b951-d872f2087c98
parent 34b5d826
......@@ -33,8 +33,8 @@ class DiffFiltererWrapper(object):
def SetCurrentFile(self, current_file):
self._current_file = current_file
@property
def _replacement_file(self):
@property
def _replacement_file(self):
return posixpath.join(self._relpath, self._current_file)
def _Replace(self, line):
......@@ -567,15 +567,18 @@ class GitWrapper(SCMWrapper):
If SCM is git-svn and the head revision is less than |rev|, git svn fetch
will be called on the source."""
sha1 = None
# Handles an SVN rev. As an optimization, only verify an SVN revision as
# [0-9]{1,6} for now to avoid making a network request.
if rev.isdigit() and len(rev) < 7:
# If the content of the safesync_url appears to be an SVN rev and the
# URL of the source appears to be git, we can only attempt to find out
# if a revision is useful after we've cloned the original URL, so just
# ignore for now.
if (os.path.isdir(self.checkout_path) and
scm.GIT.IsGitSvn(cwd=self.checkout_path)):
if not os.path.isdir(self.checkout_path):
raise gclient_utils.Error(
( 'We could not find a valid hash for safesync_url response "%s".\n'
'Safesync URLs with a git checkout currently require the repo to\n'
'be cloned without a safesync_url before adding the safesync_url.\n'
'For more info, see: '
'http://code.google.com/p/chromium/wiki/UsingNewGit'
'#Initial_checkout' ) % rev)
elif rev.isdigit() and len(rev) < 7:
# Handles an SVN rev. As an optimization, only verify an SVN revision as
# [0-9]{1,6} for now to avoid making a network request.
if scm.GIT.IsGitSvn(cwd=self.checkout_path):
local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path)
if not local_head or local_head < int(rev):
try:
......@@ -604,8 +607,15 @@ class GitWrapper(SCMWrapper):
'configured or the revision in your safesync_url is\n'
'higher than git-svn remote\'s HEAD as we couldn\'t find a\n'
'corresponding git hash for SVN rev %s.' ) % rev)
elif scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
sha1 = rev
else:
if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
sha1 = rev
else:
# May exist in origin, but we don't have it yet, so fetch and look
# again.
scm.GIT.Capture(['fetch', 'origin'], cwd=self.checkout_path)
if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
sha1 = rev
if not sha1:
raise gclient_utils.Error(
......
......@@ -1077,6 +1077,7 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
).AndReturn(False)
gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True)
gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
self.mox.ReplayAll()
......@@ -1118,6 +1119,7 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
cwd=self.base_path).AndRaise(error)
gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path)
gclient_scm.scm.GIT.Capture(['fetch', 'origin'], cwd=self.base_path)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
......@@ -1127,7 +1129,7 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1
).AndReturn(True)
gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big
).AndReturn(False)
).MultipleTimes(2).AndReturn(False)
gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True)
......
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