Commit ae7ea316 authored by smut's avatar smut

Revert "Remove all safesync_url functionality from gclient"

This reverts commit 99a7f805.
This reverts commit 2697cd19.
This reverts commit 8c51b6f1.
This reverts commit d4aedc81.

Reason for revert:
Breaks iOS release branch builds.

BUG=623762
TBR=agable,maruel

Review URL: https://codereview.chromium.org/2162583004 .
parent e29cf7cb
...@@ -18,6 +18,7 @@ class Breakpad(config_util.Config): ...@@ -18,6 +18,7 @@ class Breakpad(config_util.Config):
'url': url, 'url': url,
'managed': False, 'managed': False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -20,6 +20,7 @@ class Chromium(config_util.Config): ...@@ -20,6 +20,7 @@ class Chromium(config_util.Config):
'deps_file': '.DEPS.git', 'deps_file': '.DEPS.git',
'managed' : False, 'managed' : False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
} }
if props.get('webkit_revision', '') == 'ToT': if props.get('webkit_revision', '') == 'ToT':
solution['custom_vars'] = {'webkit_revision': ''} solution['custom_vars'] = {'webkit_revision': ''}
......
...@@ -21,6 +21,7 @@ class Dart(config_util.Config): ...@@ -21,6 +21,7 @@ class Dart(config_util.Config):
'deps_file': 'DEPS', 'deps_file': 'DEPS',
'managed' : False, 'managed' : False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -20,6 +20,7 @@ class Dartino(config_util.Config): ...@@ -20,6 +20,7 @@ class Dartino(config_util.Config):
'deps_file': 'DEPS', 'deps_file': 'DEPS',
'managed' : False, 'managed' : False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -21,6 +21,7 @@ class Dart(config_util.Config): ...@@ -21,6 +21,7 @@ class Dart(config_util.Config):
'deps_file': 'tools/deps/dartium.deps/DEPS', 'deps_file': 'tools/deps/dartium.deps/DEPS',
'managed' : False, 'managed' : False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -19,6 +19,7 @@ class Chromium(config_util.Config): ...@@ -19,6 +19,7 @@ class Chromium(config_util.Config):
'url' : url, 'url' : url,
'managed' : False, 'managed' : False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -20,6 +20,7 @@ class IOSInternal(config_util.Config): ...@@ -20,6 +20,7 @@ class IOSInternal(config_util.Config):
'deps_file': 'DEPS', 'deps_file': 'DEPS',
'managed' : False, 'managed' : False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -21,6 +21,7 @@ class Mojo(config_util.Config): ...@@ -21,6 +21,7 @@ class Mojo(config_util.Config):
'deps_file': 'DEPS', 'deps_file': 'DEPS',
'managed' : False, 'managed' : False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -22,6 +22,7 @@ class NaCl(config_util.Config): ...@@ -22,6 +22,7 @@ class NaCl(config_util.Config):
'deps_file' : 'DEPS', 'deps_file' : 'DEPS',
'managed' : False, 'managed' : False,
'custom_deps' : {}, 'custom_deps' : {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -21,6 +21,7 @@ class Naclports(config_util.Config): ...@@ -21,6 +21,7 @@ class Naclports(config_util.Config):
'deps_file' : 'DEPS', 'deps_file' : 'DEPS',
'managed' : False, 'managed' : False,
'custom_deps' : {}, 'custom_deps' : {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -21,6 +21,7 @@ class V8(config_util.Config): ...@@ -21,6 +21,7 @@ class V8(config_util.Config):
'deps_file' : 'DEPS', 'deps_file' : 'DEPS',
'managed' : False, 'managed' : False,
'custom_deps' : {}, 'custom_deps' : {},
'safesync_url': '',
} }
spec = { spec = {
'solutions': [solution], 'solutions': [solution],
......
...@@ -23,6 +23,7 @@ class WebRTC(config_util.Config): ...@@ -23,6 +23,7 @@ class WebRTC(config_util.Config):
'deps_file': 'DEPS', 'deps_file': 'DEPS',
'managed': False, 'managed': False,
'custom_deps': {}, 'custom_deps': {},
'safesync_url': '',
}, },
], ],
'with_branch_heads': True, 'with_branch_heads': True,
......
This diff is collapsed.
...@@ -30,6 +30,10 @@ GSUTIL_DEFAULT_PATH = os.path.join( ...@@ -30,6 +30,10 @@ GSUTIL_DEFAULT_PATH = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'gsutil.py') os.path.dirname(os.path.abspath(__file__)), 'gsutil.py')
class NoUsableRevError(gclient_utils.Error):
"""Raised if requested revision isn't found in checkout."""
class DiffFiltererWrapper(object): class DiffFiltererWrapper(object):
"""Simple base class which tracks which file is being diffed and """Simple base class which tracks which file is being diffed and
replaces instances of its file name in the original and replaces instances of its file name in the original and
...@@ -749,9 +753,15 @@ class GitWrapper(SCMWrapper): ...@@ -749,9 +753,15 @@ class GitWrapper(SCMWrapper):
deps_revision = default_rev deps_revision = default_rev
if deps_revision.startswith('refs/heads/'): if deps_revision.startswith('refs/heads/'):
deps_revision = deps_revision.replace('refs/heads/', self.remote + '/') deps_revision = deps_revision.replace('refs/heads/', self.remote + '/')
if not scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=deps_revision): try:
# There's a chance we just don't have the corresponding object. deps_revision = self.GetUsableRev(deps_revision, options)
self._Fetch(options) except NoUsableRevError as e:
# If the DEPS entry's url and hash changed, try to update the origin.
# See also http://crbug.com/520067.
logging.warn(
'Couldn\'t find usable revision, will retrying to update instead: %s',
e.message)
return self.update(options, [], file_list)
if file_list is not None: if file_list is not None:
files = self._Capture(['diff', deps_revision, '--name-only']).split() files = self._Capture(['diff', deps_revision, '--name-only']).split()
...@@ -782,6 +792,73 @@ class GitWrapper(SCMWrapper): ...@@ -782,6 +792,73 @@ class GitWrapper(SCMWrapper):
files = self._Capture(['diff', '--name-only', merge_base]).split() files = self._Capture(['diff', '--name-only', merge_base]).split()
file_list.extend([os.path.join(self.checkout_path, f) for f in files]) file_list.extend([os.path.join(self.checkout_path, f) for f in files])
def GetUsableRev(self, rev, options):
"""Finds a useful revision for this repository.
If SCM is git-svn and the head revision is less than |rev|, git svn fetch
will be called on the source."""
sha1 = None
if not os.path.isdir(self.checkout_path):
raise NoUsableRevError(
( '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:
logging.debug('Looking for git-svn configuration optimizations.')
if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
cwd=self.checkout_path):
self._Fetch(options)
except subprocess2.CalledProcessError:
logging.debug('git config --get svn-remote.svn.fetch failed, '
'ignoring possible optimization.')
if options.verbose:
self.Print('Running git svn fetch. This might take a while.\n')
scm.GIT.Capture(['svn', 'fetch'], cwd=self.checkout_path)
try:
sha1 = scm.GIT.GetBlessedSha1ForSvnRev(
cwd=self.checkout_path, rev=rev)
except gclient_utils.Error, e:
sha1 = e.message
self.Print('Warning: 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 NoUsableRevError(
( 'It appears that either your git-svn remote is incorrectly\n'
'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)
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.
self._Fetch(options)
if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
sha1 = rev
if not sha1:
raise NoUsableRevError(
( 'We could not find a valid hash for safesync_url response "%s".\n'
'Safesync URLs with a git checkout currently require a git-svn\n'
'remote or a safesync_url that provides git sha1s. Please add a\n'
'git-svn remote or change your safesync_url. For more info, see:\n'
'http://code.google.com/p/chromium/wiki/UsingNewGit'
'#Initial_checkout' ) % rev)
return sha1
def FullUrlForRelativeUrl(self, url): def FullUrlForRelativeUrl(self, url):
# Strip from last '/' # Strip from last '/'
# Equivalent to unix basename # Equivalent to unix basename
...@@ -1586,6 +1663,14 @@ class SVNWrapper(SCMWrapper): ...@@ -1586,6 +1663,14 @@ class SVNWrapper(SCMWrapper):
else: else:
self._RunAndGetFileList(command, options, file_list) self._RunAndGetFileList(command, options, file_list)
def GetUsableRev(self, rev, _options):
"""Verifies the validity of the revision for this repository."""
if not scm.SVN.IsValidRevision(url='%s@%s' % (self.url, rev)):
raise NoUsableRevError(
( '%s isn\'t a valid revision. Please check that your safesync_url is\n'
'correct.') % rev)
return rev
def FullUrlForRelativeUrl(self, url): def FullUrlForRelativeUrl(self, url):
# Find the forth '/' and strip from there. A bit hackish. # Find the forth '/' and strip from there. A bit hackish.
return '/'.join(self.url.split('/')[:4]) + url return '/'.join(self.url.split('/')[:4]) + url
......
...@@ -653,6 +653,12 @@ def solutions_to_git(input_solutions): ...@@ -653,6 +653,12 @@ def solutions_to_git(input_solutions):
first_solution = False first_solution = False
solution['managed'] = False solution['managed'] = False
# We don't want gclient to be using a safesync URL. Instead it should
# using the lkgr/lkcr branch/tags.
if 'safesync_url' in solution:
print 'Removing safesync url %s from %s' % (solution['safesync_url'],
parsed_path)
del solution['safesync_url']
return solutions, root, buildspec return solutions, root, buildspec
......
...@@ -133,6 +133,8 @@ class GclientApi(recipe_api.RecipeApi): ...@@ -133,6 +133,8 @@ class GclientApi(recipe_api.RecipeApi):
revisions = [] revisions = []
self.set_patch_project_revision(self.m.properties.get('patch_project'), cfg) self.set_patch_project_revision(self.m.properties.get('patch_project'), cfg)
for i, s in enumerate(cfg.solutions): for i, s in enumerate(cfg.solutions):
if s.safesync_url: # prefer safesync_url in gclient mode
continue
if i == 0 and s.revision is None: if i == 0 and s.revision is None:
s.revision = RevisionFallbackChain() s.revision = RevisionFallbackChain()
......
...@@ -25,6 +25,7 @@ def BaseConfig(USE_MIRROR=True, GIT_MODE=False, CACHE_DIR=None, ...@@ -25,6 +25,7 @@ def BaseConfig(USE_MIRROR=True, GIT_MODE=False, CACHE_DIR=None,
managed = Single(bool, empty_val=True, required=False, hidden=False), managed = Single(bool, empty_val=True, required=False, hidden=False),
custom_deps = Dict(value_type=(basestring, types.NoneType)), custom_deps = Dict(value_type=(basestring, types.NoneType)),
custom_vars = Dict(value_type=basestring), custom_vars = Dict(value_type=basestring),
safesync_url = Single(basestring, required=False),
revision = Single( revision = Single(
(basestring, gclient_api.RevisionResolver), (basestring, gclient_api.RevisionResolver),
...@@ -185,12 +186,24 @@ def chromium(c): ...@@ -185,12 +186,24 @@ def chromium(c):
@config_ctx(includes=['chromium']) @config_ctx(includes=['chromium'])
def chromium_lkcr(c): def chromium_lkcr(c):
# TODO(phajdan.jr): Add git hashes for LKCR crbug.com/349277.
if c.GIT_MODE:
raise BadConf('Git has problems with safesync_url and LKCR, '
'crbug.com/349277 crbug.com/109191') # pragma: no cover
s = c.solutions[0] s = c.solutions[0]
s.safesync_url = 'https://build.chromium.org/p/chromium/lkcr-status/lkgr'
# TODO(hinoka): Once lkcr exists and is a tag, it should just be lkcr
# rather than origin/lkcr.
s.revision = 'origin/lkcr' s.revision = 'origin/lkcr'
@config_ctx(includes=['chromium']) @config_ctx(includes=['chromium'])
def chromium_lkgr(c): def chromium_lkgr(c):
s = c.solutions[0] s = c.solutions[0]
safesync_url = 'https://chromium-status.appspot.com/lkgr'
if c.GIT_MODE: # pragma: no cover
safesync_url = 'https://chromium-status.appspot.com/git-lkgr'
raise BadConf('Git has problems with safesync_url, crbug.com/109191.')
s.safesync_url = safesync_url
s.revision = 'origin/lkgr' s.revision = 'origin/lkgr'
@config_ctx(includes=['chromium_bare']) @config_ctx(includes=['chromium_bare'])
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
"RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py",
"config", "config",
"--spec", "--spec",
"cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'url': 'svn://svn.chromium.org/blink/trunk'}]" "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]"
], ],
"cwd": "[SLAVE_BUILD]/src/third_party", "cwd": "[SLAVE_BUILD]/src/third_party",
"env": { "env": {
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
"RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py",
"config", "config",
"--spec", "--spec",
"cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'url': 'svn://svn.chromium.org/blink/trunk'}]" "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]"
], ],
"cwd": "[SLAVE_BUILD]/src/third_party", "cwd": "[SLAVE_BUILD]/src/third_party",
"env": { "env": {
...@@ -107,8 +107,6 @@ ...@@ -107,8 +107,6 @@
"--delete_unversioned_trees", "--delete_unversioned_trees",
"--with_branch_heads", "--with_branch_heads",
"--revision", "--revision",
"WebKit@abc",
"--revision",
"third_party/WebKit@123", "third_party/WebKit@123",
"--output-json", "--output-json",
"/path/to/tmp/json" "/path/to/tmp/json"
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
"RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py",
"config", "config",
"--spec", "--spec",
"cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'url': 'svn://svn.chromium.org/blink/trunk'}]" "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]"
], ],
"cwd": "[SLAVE_BUILD]/src/third_party", "cwd": "[SLAVE_BUILD]/src/third_party",
"env": { "env": {
...@@ -118,8 +118,6 @@ ...@@ -118,8 +118,6 @@
"--delete_unversioned_trees", "--delete_unversioned_trees",
"--with_branch_heads", "--with_branch_heads",
"--revision", "--revision",
"WebKit@HEAD",
"--revision",
"third_party/WebKit@123", "third_party/WebKit@123",
"--output-json", "--output-json",
"/path/to/tmp/json" "/path/to/tmp/json"
......
...@@ -76,6 +76,9 @@ def RunSteps(api): ...@@ -76,6 +76,9 @@ def RunSteps(api):
soln.url = 'svn://svn.chromium.org/blink/trunk' soln.url = 'svn://svn.chromium.org/blink/trunk'
bl_cfg.revisions['third_party/WebKit'] = '123' bl_cfg.revisions['third_party/WebKit'] = '123'
# Use safesync url for lkgr.
soln.safesync_url = 'https://blink-status.appspot.com/lkgr'
bl_cfg.got_revision_mapping['src/blatley'] = 'got_blatley_revision' bl_cfg.got_revision_mapping['src/blatley'] = 'got_blatley_revision'
api.gclient.checkout( api.gclient.checkout(
gclient_config=bl_cfg, gclient_config=bl_cfg,
......
...@@ -600,6 +600,106 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase): ...@@ -600,6 +600,106 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
def tearDown(self): def tearDown(self):
BaseTestCase.tearDown(self) BaseTestCase.tearDown(self)
def testGetUsableRevGit(self):
# pylint: disable=E1101
options = self.Options(verbose=True)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1
).AndReturn(True)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
).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()
git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
relpath=self.relpath)
# A [fake] git sha1 with a git repo should work (this is in the case that
# the LKGR gets flipped to git sha1's some day).
self.assertEquals(git_scm.GetUsableRev(self.fake_hash_1, options),
self.fake_hash_1)
# An SVN rev with an existing purely git repo should raise an exception.
self.assertRaises(gclient_scm.gclient_utils.Error,
git_scm.GetUsableRev, '1', options)
def testGetUsableRevGitSvn(self):
# pylint: disable=E1101
options = self.Options()
too_big = str(1e7)
# Pretend like the git-svn repo's HEAD is at r2.
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'GetGitSvnHeadRev', True)
gclient_scm.scm.GIT.GetGitSvnHeadRev(cwd=self.base_path).MultipleTimes(
).AndReturn(2)
self.mox.StubOutWithMock(
gclient_scm.scm.GIT, 'GetBlessedSha1ForSvnRev', True)
# r1 -> first fake hash, r3 -> second fake hash.
gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='1'
).AndReturn(self.fake_hash_1)
gclient_scm.scm.GIT.GetBlessedSha1ForSvnRev(cwd=self.base_path, rev='3'
).MultipleTimes().AndReturn(self.fake_hash_2)
# Ensure that we call git svn fetch if our LKGR is > the git-svn HEAD rev.
self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Fetch', True)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True)
gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
cwd=self.base_path).AndReturn('blah')
# pylint: disable=E1120
gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path)
error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr')
gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
cwd=self.base_path).AndRaise(error)
gclient_scm.GitWrapper._Fetch(options)
gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path)
gclient_scm.GitWrapper._Fetch(options)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
).AndReturn(True)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
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
).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)
self.mox.ReplayAll()
git_svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
relpath=self.relpath)
# Without an existing checkout, this should fail.
# TODO(dbeam) Fix this. http://crbug.com/109184
self.assertRaises(gclient_scm.gclient_utils.Error,
git_svn_scm.GetUsableRev, '1', options)
# Given an SVN revision with a git-svn checkout, it should be translated to
# a git sha1 and be usable.
self.assertEquals(git_svn_scm.GetUsableRev('1', options),
self.fake_hash_1)
# Our fake HEAD rev is r2, so this should call git fetch and git svn fetch
# to get more revs (pymox will complain if this doesn't happen). We mock an
# optimized checkout the first time, so this run should call git fetch.
self.assertEquals(git_svn_scm.GetUsableRev('3', options),
self.fake_hash_2)
# The time we pretend we're not optimized, so no git fetch should fire.
self.assertEquals(git_svn_scm.GetUsableRev('3', options),
self.fake_hash_2)
# Given a git sha1 with a git-svn checkout, it should be used as is.
self.assertEquals(git_svn_scm.GetUsableRev(self.fake_hash_1, options),
self.fake_hash_1)
# We currently check for seemingly valid SVN revisions by assuming 6 digit
# numbers, so assure that numeric revs >= 1000000 don't work.
self.assertRaises(gclient_scm.gclient_utils.Error,
git_svn_scm.GetUsableRev, too_big, options)
def testUpdateNoDotGit(self): def testUpdateNoDotGit(self):
options = self.Options() options = self.Options()
......
...@@ -205,36 +205,52 @@ class GClientSmoke(GClientSmokeBase): ...@@ -205,36 +205,52 @@ class GClientSmoke(GClientSmokeBase):
test(['config', self.svn_base + 'trunk/src/'], test(['config', self.svn_base + 'trunk/src/'],
('solutions = [\n' ('solutions = [\n'
' {\n' ' { "name" : "src",\n'
' "name" : "src",\n'
' "url" : "%strunk/src",\n' ' "url" : "%strunk/src",\n'
' "deps_file" : "DEPS",\n' ' "deps_file" : "DEPS",\n'
' "managed" : False,\n' ' "managed" : True,\n'
' "custom_deps" : {},\n' ' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
' },\n' ' },\n'
']\n' ']\n'
'cache_dir = None\n') % self.svn_base) 'cache_dir = None\n') % self.svn_base)
test(['config', self.git_base + 'repo_1', '--name', 'src'], test(['config', self.git_base + 'repo_1', '--name', 'src'],
('solutions = [\n' ('solutions = [\n'
' {\n' ' { "name" : "src",\n'
' "name" : "src",\n'
' "url" : "%srepo_1",\n' ' "url" : "%srepo_1",\n'
' "deps_file" : "DEPS",\n' ' "deps_file" : "DEPS",\n'
' "managed" : False,\n' ' "managed" : True,\n'
' "custom_deps" : {},\n' ' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
' },\n' ' },\n'
']\n' ']\n'
'cache_dir = None\n') % self.git_base) 'cache_dir = None\n') % self.git_base)
test(['config', 'foo', 'faa'],
'solutions = [\n'
' { "name" : "foo",\n'
' "url" : "foo",\n'
' "deps_file" : "DEPS",\n'
' "managed" : True,\n'
' "custom_deps" : {\n'
' },\n'
' "safesync_url": "faa",\n'
' },\n'
']\n'
'cache_dir = None\n')
test(['config', 'foo', '--deps', 'blah'], test(['config', 'foo', '--deps', 'blah'],
'solutions = [\n' 'solutions = [\n'
' {\n' ' { "name" : "foo",\n'
' "name" : "foo",\n'
' "url" : "foo",\n' ' "url" : "foo",\n'
' "deps_file" : "blah",\n' ' "deps_file" : "blah",\n'
' "managed" : False,\n' ' "managed" : True,\n'
' "custom_deps" : {},\n' ' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
' },\n' ' },\n'
']\n' ']\n'
'cache_dir = None\n') 'cache_dir = None\n')
...@@ -243,7 +259,7 @@ class GClientSmoke(GClientSmokeBase): ...@@ -243,7 +259,7 @@ class GClientSmoke(GClientSmokeBase):
os.remove(p) os.remove(p)
results = self.gclient(['config', 'foo', 'faa', 'fuu']) results = self.gclient(['config', 'foo', 'faa', 'fuu'])
err = ('Usage: gclient.py config [options] [url]\n\n' err = ('Usage: gclient.py config [options] [url] [safesync url]\n\n'
'gclient.py: error: Inconsistent arguments. Use either --spec or one' 'gclient.py: error: Inconsistent arguments. Use either --spec or one'
' or 2 args\n') ' or 2 args\n')
self.check(('', err, 2), results) self.check(('', err, 2), results)
...@@ -287,14 +303,14 @@ class GClientSmokeGIT(GClientSmokeBase): ...@@ -287,14 +303,14 @@ class GClientSmokeGIT(GClientSmokeBase):
super(GClientSmokeGIT, self).setUp() super(GClientSmokeGIT, self).setUp()
self.enabled = self.FAKE_REPOS.set_up_git() self.enabled = self.FAKE_REPOS.set_up_git()
def testSyncManaged(self): def testSync(self):
if not self.enabled: if not self.enabled:
return return
self.gclient([ # TODO(maruel): safesync.
'config', self.git_base + 'repo_1', '--name', 'src', '--managed']) self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
# Test unversioned checkout. # Test unversioned checkout.
self.parseGclient( self.parseGclient(
['sync', '--deps', 'mac', '--jobs', '8'], ['sync', '--deps', 'mac', '--jobs', '1'],
['running', 'running']) ['running', 'running'])
# TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must
# add sync parsing to get the list of updated files. # add sync parsing to get the list of updated files.
...@@ -312,7 +328,7 @@ class GClientSmokeGIT(GClientSmokeBase): ...@@ -312,7 +328,7 @@ class GClientSmokeGIT(GClientSmokeBase):
# Test incremental versioned sync: sync backward. # Test incremental versioned sync: sync backward.
self.parseGclient( self.parseGclient(
['sync', '--jobs', '1', '--revision', ['sync', '--jobs', '1', '--revision',
'src@' + self.githash('repo_1', 1), '--jobs', '1', 'src@' + self.githash('repo_1', 1),
'--deps', 'mac', '--delete_unversioned_trees'], '--deps', 'mac', '--delete_unversioned_trees'],
['deleting']) ['deleting'])
tree = self.mangle_git_tree(('repo_1@1', 'src'), tree = self.mangle_git_tree(('repo_1@1', 'src'),
...@@ -323,7 +339,7 @@ class GClientSmokeGIT(GClientSmokeBase): ...@@ -323,7 +339,7 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertTree(tree) self.assertTree(tree)
# Test incremental sync: delete-unversioned_trees isn't there. # Test incremental sync: delete-unversioned_trees isn't there.
self.parseGclient( self.parseGclient(
['sync', '--deps', 'mac', '--jobs', '8'], ['sync', '--deps', 'mac', '--jobs', '1'],
['running', 'running']) ['running', 'running'])
tree = self.mangle_git_tree(('repo_1@2', 'src'), tree = self.mangle_git_tree(('repo_1@2', 'src'),
('repo_2@1', 'src/repo2'), ('repo_2@1', 'src/repo2'),
...@@ -367,6 +383,56 @@ class GClientSmokeGIT(GClientSmokeBase): ...@@ -367,6 +383,56 @@ class GClientSmokeGIT(GClientSmokeBase):
('repo_4@2', 'src/repo4')) ('repo_4@2', 'src/repo4'))
self.assertTree(tree) self.assertTree(tree)
def testSyncJobs(self):
if not self.enabled:
return
# TODO(maruel): safesync.
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
# Test unversioned checkout.
self.parseGclient(
['sync', '--deps', 'mac', '--jobs', '8'],
['running', 'running'],
untangle=True)
# TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must
# add sync parsing to get the list of updated files.
tree = self.mangle_git_tree(('repo_1@2', 'src'),
('repo_2@1', 'src/repo2'),
('repo_3@2', 'src/repo2/repo_renamed'))
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
# Manually remove git_hooked1 before synching to make sure it's not
# recreated.
os.remove(join(self.root_dir, 'src', 'git_hooked1'))
# Test incremental versioned sync: sync backward.
# Use --jobs 1 otherwise the order is not deterministic.
self.parseGclient(
['sync', '--revision', 'src@' + self.githash('repo_1', 1),
'--deps', 'mac', '--delete_unversioned_trees', '--jobs', '1'],
['deleting'],
untangle=True)
tree = self.mangle_git_tree(('repo_1@1', 'src'),
('repo_2@2', 'src/repo2'),
('repo_3@1', 'src/repo2/repo3'),
('repo_4@2', 'src/repo4'))
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
# Test incremental sync: delete-unversioned_trees isn't there.
self.parseGclient(
['sync', '--deps', 'mac', '--jobs', '8'],
['running', 'running'],
untangle=True)
tree = self.mangle_git_tree(('repo_1@2', 'src'),
('repo_2@1', 'src/repo2'),
('repo_3@1', 'src/repo2/repo3'),
('repo_3@2', 'src/repo2/repo_renamed'),
('repo_4@2', 'src/repo4'))
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)
def testRunHooks(self): def testRunHooks(self):
if not self.enabled: if not self.enabled:
return return
......
...@@ -216,7 +216,7 @@ class GclientTest(trial_dir.TestCase): ...@@ -216,7 +216,7 @@ class GclientTest(trial_dir.TestCase):
# Invalid urls causes pain when specifying requirements. Make sure it's # Invalid urls causes pain when specifying requirements. Make sure it's
# auto-fixed. # auto-fixed.
d = gclient.Dependency( d = gclient.Dependency(
None, 'name', 'proto://host/path/@revision', None, None, None, None, 'name', 'proto://host/path/@revision', None, None, None, None,
None, '', True) None, '', True)
self.assertEquals('proto://host/path@revision', d.url) self.assertEquals('proto://host/path@revision', d.url)
...@@ -227,23 +227,23 @@ class GclientTest(trial_dir.TestCase): ...@@ -227,23 +227,23 @@ class GclientTest(trial_dir.TestCase):
obj.add_dependencies_and_close( obj.add_dependencies_and_close(
[ [
gclient.Dependency( gclient.Dependency(
obj, 'foo', 'url', None, None, None, None, 'DEPS', True), obj, 'foo', 'url', None, None, None, None, None, 'DEPS', True),
gclient.Dependency( gclient.Dependency(
obj, 'bar', 'url', None, None, None, None, 'DEPS', True), obj, 'bar', 'url', None, None, None, None, None, 'DEPS', True),
], ],
[]) [])
obj.dependencies[0].add_dependencies_and_close( obj.dependencies[0].add_dependencies_and_close(
[ [
gclient.Dependency( gclient.Dependency(
obj.dependencies[0], 'foo/dir1', 'url', None, None, None, obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None,
None, 'DEPS', True), None, 'DEPS', True),
gclient.Dependency( gclient.Dependency(
obj.dependencies[0], 'foo/dir2', obj.dependencies[0], 'foo/dir2',
gclient.GClientKeywords.FromImpl('bar'), None, None, None, gclient.GClientKeywords.FromImpl('bar'), None, None, None, None,
None, 'DEPS', True), None, 'DEPS', True),
gclient.Dependency( gclient.Dependency(
obj.dependencies[0], 'foo/dir3', obj.dependencies[0], 'foo/dir3',
gclient.GClientKeywords.FileImpl('url'), None, None, None, gclient.GClientKeywords.FileImpl('url'), None, None, None, None,
None, 'DEPS', True), None, 'DEPS', True),
], ],
[]) [])
...@@ -564,7 +564,7 @@ class GclientTest(trial_dir.TestCase): ...@@ -564,7 +564,7 @@ class GclientTest(trial_dir.TestCase):
"""Verifies expected behavior of LateOverride.""" """Verifies expected behavior of LateOverride."""
url = "git@github.com:dart-lang/spark.git" url = "git@github.com:dart-lang/spark.git"
d = gclient.Dependency(None, 'name', 'url', d = gclient.Dependency(None, 'name', 'url',
None, None, None, None, '', True) None, None, None, None, None, '', True)
late_url = d.LateOverride(url) late_url = d.LateOverride(url)
self.assertEquals(url, late_url) self.assertEquals(url, late_url)
......
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