Commit 99a7f805 authored by agable's avatar agable Committed by Commit bot

Remove all safesync_url functionality from gclient

R=maruel@chromium.org
BUG=109184

Review-Url: https://codereview.chromium.org/2087313002
parent 96e179bb
......@@ -18,7 +18,6 @@ class Breakpad(config_util.Config):
'url': url,
'managed': False,
'custom_deps': {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -20,7 +20,6 @@ class Chromium(config_util.Config):
'deps_file': '.DEPS.git',
'managed' : False,
'custom_deps': {},
'safesync_url': '',
}
if props.get('webkit_revision', '') == 'ToT':
solution['custom_vars'] = {'webkit_revision': ''}
......
......@@ -21,7 +21,6 @@ class Dart(config_util.Config):
'deps_file': 'DEPS',
'managed' : False,
'custom_deps': {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -20,7 +20,6 @@ class Dartino(config_util.Config):
'deps_file': 'DEPS',
'managed' : False,
'custom_deps': {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -21,7 +21,6 @@ class Dart(config_util.Config):
'deps_file': 'tools/deps/dartium.deps/DEPS',
'managed' : False,
'custom_deps': {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -19,7 +19,6 @@ class Chromium(config_util.Config):
'url' : url,
'managed' : False,
'custom_deps': {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -20,7 +20,6 @@ class IOSInternal(config_util.Config):
'deps_file': 'DEPS',
'managed' : False,
'custom_deps': {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -21,7 +21,6 @@ class Mojo(config_util.Config):
'deps_file': 'DEPS',
'managed' : False,
'custom_deps': {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -22,7 +22,6 @@ class NaCl(config_util.Config):
'deps_file' : 'DEPS',
'managed' : False,
'custom_deps' : {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -21,7 +21,6 @@ class Naclports(config_util.Config):
'deps_file' : 'DEPS',
'managed' : False,
'custom_deps' : {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -21,7 +21,6 @@ class V8(config_util.Config):
'deps_file' : 'DEPS',
'managed' : False,
'custom_deps' : {},
'safesync_url': '',
}
spec = {
'solutions': [solution],
......
......@@ -23,7 +23,6 @@ class WebRTC(config_util.Config):
'deps_file': 'DEPS',
'managed': False,
'custom_deps': {},
'safesync_url': '',
},
],
'with_branch_heads': True,
......
......@@ -213,13 +213,12 @@ class GClientKeywords(object):
class DependencySettings(GClientKeywords):
"""Immutable configuration settings."""
def __init__(
self, parent, url, safesync_url, managed, custom_deps, custom_vars,
self, parent, url, managed, custom_deps, custom_vars,
custom_hooks, deps_file, should_process):
GClientKeywords.__init__(self)
# These are not mutable:
self._parent = parent
self._safesync_url = safesync_url
self._deps_file = deps_file
self._url = url
# 'managed' determines whether or not this dependency is synced/updated by
......@@ -281,10 +280,6 @@ class DependencySettings(GClientKeywords):
return self or GClient(None, None)
return self.parent.root
@property
def safesync_url(self):
return self._safesync_url
@property
def should_process(self):
"""True if this dependency should be processed, i.e. checked out."""
......@@ -324,11 +319,11 @@ class DependencySettings(GClientKeywords):
class Dependency(gclient_utils.WorkItem, DependencySettings):
"""Object that represents a dependency checkout."""
def __init__(self, parent, name, url, safesync_url, managed, custom_deps,
def __init__(self, parent, name, url, managed, custom_deps,
custom_vars, custom_hooks, deps_file, should_process):
gclient_utils.WorkItem.__init__(self, name)
DependencySettings.__init__(
self, parent, url, safesync_url, managed, custom_deps, custom_vars,
self, parent, url, managed, custom_deps, custom_vars,
custom_hooks, deps_file, should_process)
# This is in both .gclient and DEPS files:
......@@ -727,7 +722,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
if ent is not None:
deps_file = ent['deps_file']
deps_to_add.append(Dependency(
self, name, url, None, None, None, self.custom_vars, None,
self, name, url, None, None, self.custom_vars, None,
deps_file, should_process))
deps_to_add.sort(key=lambda x: x.name)
......@@ -1134,7 +1129,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
def __str__(self):
out = []
for i in ('name', 'url', 'parsed_url', 'safesync_url', 'custom_deps',
for i in ('name', 'url', 'parsed_url', 'custom_deps',
'custom_vars', 'deps_hooks', 'file_list', 'should_process',
'processed', 'hooks_ran', 'deps_parsed', 'requirements',
'allowed_hosts'):
......@@ -1183,26 +1178,26 @@ class GClient(Dependency):
DEFAULT_CLIENT_FILE_TEXT = ("""\
solutions = [
{ "name" : "%(solution_name)s",
{
"name" : "%(solution_name)s",
"url" : "%(solution_url)s",
"deps_file" : "%(deps_file)s",
"managed" : %(managed)s,
"custom_deps" : {
},
"safesync_url": "%(safesync_url)s",
"custom_deps" : {},
},
]
cache_dir = %(cache_dir)r
""")
DEFAULT_SNAPSHOT_SOLUTION_TEXT = ("""\
{ "name" : "%(solution_name)s",
{
"name" : "%(solution_name)s",
"url" : "%(solution_url)s",
"deps_file" : "%(deps_file)s",
"managed" : %(managed)s,
"custom_deps" : {
%(solution_deps)s },
"safesync_url": "%(safesync_url)s",
%(solution_deps)s
},
},
""")
......@@ -1216,7 +1211,7 @@ solutions = [
# Do not change previous behavior. Only solution level and immediate DEPS
# are processed.
self._recursion_limit = 2
Dependency.__init__(self, None, None, None, None, True, None, None, None,
Dependency.__init__(self, None, None, None, True, None, None, None,
'unused', True)
self._options = options
if options.deps_os:
......@@ -1299,10 +1294,12 @@ want to set 'managed': False in .gclient.
deps_to_add = []
for s in config_dict.get('solutions', []):
if s.get('safesync_url'):
raise gclient_utils.Error('safesync_url is not supported anymore. '
'Please remove it from your .gclient file.')
try:
deps_to_add.append(Dependency(
self, s['name'], s['url'],
s.get('safesync_url', None),
s.get('managed', True),
s.get('custom_deps', {}),
s.get('custom_vars', {}),
......@@ -1429,12 +1426,11 @@ been automagically updated. The previous version is available at %s.old.
return client
def SetDefaultConfig(self, solution_name, deps_file, solution_url,
safesync_url, managed=True, cache_dir=None):
managed=True, cache_dir=None):
self.SetConfig(self.DEFAULT_CLIENT_FILE_TEXT % {
'solution_name': solution_name,
'solution_url': solution_url,
'deps_file': deps_file,
'safesync_url' : safesync_url,
'managed': managed,
'cache_dir': cache_dir,
})
......@@ -1477,15 +1473,10 @@ been automagically updated. The previous version is available at %s.old.
def _EnforceRevisions(self):
"""Checks for revision overrides."""
revision_overrides = {}
if self._options.head:
return revision_overrides
# Do not check safesync_url if one or more --revision flag is specified.
if not self._options.revisions:
for s in self.dependencies:
if not s.managed:
self._options.revisions.append('%s@unmanaged' % s.name)
elif s.safesync_url:
self._ApplySafeSyncRev(dep=s)
if not self._options.revisions:
return revision_overrides
solutions_names = [s.name for s in self.dependencies]
......@@ -1499,26 +1490,6 @@ been automagically updated. The previous version is available at %s.old.
index += 1
return revision_overrides
def _ApplySafeSyncRev(self, dep):
"""Finds a valid revision from the content of the safesync_url and apply it
by appending revisions to the revision list. Throws if revision appears to
be invalid for the given |dep|."""
assert len(dep.safesync_url) > 0
handle = urllib.urlopen(dep.safesync_url)
rev = handle.read().strip()
handle.close()
if not rev:
raise gclient_utils.Error(
'It appears your safesync_url (%s) is not working properly\n'
'(as it returned an empty response). Check your config.' %
dep.safesync_url)
scm = gclient_scm.CreateSCM(
dep.url, dep.root.root_dir, dep.name, self.outbuf)
safe_rev = scm.GetUsableRev(rev, self._options)
if self._options.verbose:
print('Using safesync_url revision: %s.\n' % safe_rev)
self._options.revisions.append('%s@%s' % (dep.name, safe_rev))
def RunOnDeps(self, command, args, ignore_requirements=False, progress=True):
"""Runs a command on each dependency in a client and its dependencies.
......@@ -1703,7 +1674,6 @@ been automagically updated. The previous version is available at %s.old.
'solution_name': d.name,
'solution_url': d.url,
'deps_file': d.deps_file,
'safesync_url' : d.safesync_url or '',
'managed': d.managed,
'solution_deps': ''.join(custom_deps),
}
......@@ -1869,7 +1839,7 @@ def CMDroot(parser, args):
print(os.path.abspath('.'))
@subcommand.usage('[url] [safesync url]')
@subcommand.usage('[url]')
def CMDconfig(parser, args):
"""Creates a .gclient file in the current directory.
......@@ -1928,10 +1898,7 @@ def CMDconfig(parser, args):
parser.error('Do not include relative path components in --name.')
deps_file = options.deps_file
safesync_url = ''
if len(args) > 1:
safesync_url = args[1]
client.SetDefaultConfig(name, deps_file, base_url, safesync_url,
client.SetDefaultConfig(name, deps_file, base_url,
managed=not options.unmanaged,
cache_dir=options.cache_dir)
client.SaveConfig()
......@@ -2020,8 +1987,7 @@ def CMDsync(parser, args):
'format src@rev. The src@ part is optional and can be '
'skipped. -r can be used multiple times when .gclient '
'has multiple solutions configured and will work even '
'if the src@ part is skipped. Note that specifying '
'--revision means your safesync_url gets ignored.')
'if the src@ part is skipped.')
parser.add_option('--with_branch_heads', action='store_true',
help='Clone git "branch_heads" refspecs in addition to '
'the default refspecs. This adds about 1/2GB to a '
......@@ -2033,9 +1999,6 @@ def CMDsync(parser, args):
'with the command-line flag), transitively update '
'the dependencies to the date of the given revision. '
'Only supported for SVN repositories.')
parser.add_option('-H', '--head', action='store_true',
help='skips any safesync_urls specified in '
'configured solutions and sync to head instead')
parser.add_option('-D', '--delete_unversioned_trees', action='store_true',
help='Deletes from the working copy any dependencies that '
'have been removed since the last sync, as long as '
......@@ -2090,10 +2053,6 @@ def CMDsync(parser, args):
if not client:
raise gclient_utils.Error('client not configured; see \'gclient config\'')
if options.revisions and options.head:
# TODO(maruel): Make it a parser.error if it doesn't break any builder.
print('Warning: you cannot use both --head and --revision')
if options.verbose:
client.PrintLocationAndContents()
ret = client.RunOnDeps('update', args)
......@@ -2300,8 +2259,6 @@ class OptionParser(optparse.OptionParser):
if not hasattr(options, 'revisions'):
# GClient.RunOnDeps expects it even if not applicable.
options.revisions = []
if not hasattr(options, 'head'):
options.head = None
if not hasattr(options, 'nohooks'):
options.nohooks = True
if not hasattr(options, 'noprehooks'):
......
......@@ -30,10 +30,6 @@ GSUTIL_DEFAULT_PATH = os.path.join(
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):
"""Simple base class which tracks which file is being diffed and
replaces instances of its file name in the original and
......@@ -753,15 +749,9 @@ class GitWrapper(SCMWrapper):
deps_revision = default_rev
if deps_revision.startswith('refs/heads/'):
deps_revision = deps_revision.replace('refs/heads/', self.remote + '/')
try:
deps_revision = self.GetUsableRev(deps_revision, 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 not scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=deps_revision):
# There's a chance we just don't have the corresponding object.
self._Fetch(options)
if file_list is not None:
files = self._Capture(['diff', deps_revision, '--name-only']).split()
......@@ -792,73 +782,6 @@ class GitWrapper(SCMWrapper):
files = self._Capture(['diff', '--name-only', merge_base]).split()
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):
# Strip from last '/'
# Equivalent to unix basename
......@@ -1663,14 +1586,6 @@ class SVNWrapper(SCMWrapper):
else:
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):
# Find the forth '/' and strip from there. A bit hackish.
return '/'.join(self.url.split('/')[:4]) + url
......
......@@ -651,12 +651,6 @@ def solutions_to_git(input_solutions):
first_solution = 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
......
......@@ -150,8 +150,6 @@ class GclientApi(recipe_api.RecipeApi):
revisions = []
self.set_patch_project_revision(self.m.properties.get('patch_project'), cfg)
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:
s.revision = RevisionFallbackChain()
......
......@@ -25,7 +25,6 @@ def BaseConfig(USE_MIRROR=True, GIT_MODE=False, CACHE_DIR=None,
managed = Single(bool, empty_val=True, required=False, hidden=False),
custom_deps = Dict(value_type=(basestring, types.NoneType)),
custom_vars = Dict(value_type=basestring),
safesync_url = Single(basestring, required=False),
revision = Single(
(basestring, gclient_api.RevisionResolver),
......@@ -186,24 +185,12 @@ def chromium(c):
@config_ctx(includes=['chromium'])
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.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'
@config_ctx(includes=['chromium'])
def chromium_lkgr(c):
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'
@config_ctx(includes=['chromium_bare'])
......
......@@ -85,7 +85,7 @@
"RECIPE_PACKAGE_REPO[depot_tools]/gclient.py",
"config",
"--spec",
"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'}]"
"cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'url': 'svn://svn.chromium.org/blink/trunk'}]"
],
"cwd": "[SLAVE_BUILD]/src/third_party",
"env": {
......
......@@ -87,7 +87,7 @@
"RECIPE_PACKAGE_REPO[depot_tools]/gclient.py",
"config",
"--spec",
"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'}]"
"cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'url': 'svn://svn.chromium.org/blink/trunk'}]"
],
"cwd": "[SLAVE_BUILD]/src/third_party",
"env": {
......@@ -107,6 +107,8 @@
"--delete_unversioned_trees",
"--with_branch_heads",
"--revision",
"WebKit@abc",
"--revision",
"third_party/WebKit@123",
"--output-json",
"/path/to/tmp/json"
......
......@@ -87,7 +87,7 @@
"RECIPE_PACKAGE_REPO[depot_tools]/gclient.py",
"config",
"--spec",
"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'}]"
"cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'url': 'svn://svn.chromium.org/blink/trunk'}]"
],
"cwd": "[SLAVE_BUILD]/src/third_party",
"env": {
......@@ -118,6 +118,8 @@
"--delete_unversioned_trees",
"--with_branch_heads",
"--revision",
"WebKit@HEAD",
"--revision",
"third_party/WebKit@123",
"--output-json",
"/path/to/tmp/json"
......
......@@ -77,9 +77,6 @@ def RunSteps(api):
soln.url = 'svn://svn.chromium.org/blink/trunk'
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'
api.gclient.checkout(
gclient_config=bl_cfg,
......
......@@ -600,106 +600,6 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
def 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):
options = self.Options()
......
......@@ -205,52 +205,36 @@ class GClientSmoke(GClientSmokeBase):
test(['config', self.svn_base + 'trunk/src/'],
('solutions = [\n'
' { "name" : "src",\n'
' {\n'
' "name" : "src",\n'
' "url" : "%strunk/src",\n'
' "deps_file" : "DEPS",\n'
' "managed" : True,\n'
' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
' "custom_deps" : {},\n'
' },\n'
']\n'
'cache_dir = None\n') % self.svn_base)
test(['config', self.git_base + 'repo_1', '--name', 'src'],
('solutions = [\n'
' { "name" : "src",\n'
' {\n'
' "name" : "src",\n'
' "url" : "%srepo_1",\n'
' "deps_file" : "DEPS",\n'
' "managed" : True,\n'
' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
' "custom_deps" : {},\n'
' },\n'
']\n'
'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'],
'solutions = [\n'
' { "name" : "foo",\n'
' {\n'
' "name" : "foo",\n'
' "url" : "foo",\n'
' "deps_file" : "blah",\n'
' "managed" : True,\n'
' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
' "custom_deps" : {},\n'
' },\n'
']\n'
'cache_dir = None\n')
......@@ -259,7 +243,7 @@ class GClientSmoke(GClientSmokeBase):
os.remove(p)
results = self.gclient(['config', 'foo', 'faa', 'fuu'])
err = ('Usage: gclient.py config [options] [url] [safesync url]\n\n'
err = ('Usage: gclient.py config [options] [url]\n\n'
'gclient.py: error: Inconsistent arguments. Use either --spec or one'
' or 2 args\n')
self.check(('', err, 2), results)
......@@ -306,7 +290,6 @@ class GClientSmokeGIT(GClientSmokeBase):
def testSync(self):
if not self.enabled:
return
# TODO(maruel): safesync.
self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
# Test unversioned checkout.
self.parseGclient(
......@@ -386,7 +369,6 @@ class GClientSmokeGIT(GClientSmokeBase):
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(
......
......@@ -216,7 +216,7 @@ class GclientTest(trial_dir.TestCase):
# Invalid urls causes pain when specifying requirements. Make sure it's
# auto-fixed.
d = gclient.Dependency(
None, 'name', 'proto://host/path/@revision', None, None, None, None,
None, 'name', 'proto://host/path/@revision', None, None, None,
None, '', True)
self.assertEquals('proto://host/path@revision', d.url)
......@@ -227,23 +227,23 @@ class GclientTest(trial_dir.TestCase):
obj.add_dependencies_and_close(
[
gclient.Dependency(
obj, 'foo', 'url', None, None, None, None, None, 'DEPS', True),
obj, 'foo', 'url', None, None, None, None, 'DEPS', True),
gclient.Dependency(
obj, 'bar', 'url', None, None, None, None, None, 'DEPS', True),
obj, 'bar', 'url', None, None, None, None, 'DEPS', True),
],
[])
obj.dependencies[0].add_dependencies_and_close(
[
gclient.Dependency(
obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None,
obj.dependencies[0], 'foo/dir1', 'url', None, None, None,
None, 'DEPS', True),
gclient.Dependency(
obj.dependencies[0], 'foo/dir2',
gclient.GClientKeywords.FromImpl('bar'), None, None, None, None,
gclient.GClientKeywords.FromImpl('bar'), None, None, None,
None, 'DEPS', True),
gclient.Dependency(
obj.dependencies[0], 'foo/dir3',
gclient.GClientKeywords.FileImpl('url'), None, None, None, None,
gclient.GClientKeywords.FileImpl('url'), None, None, None,
None, 'DEPS', True),
],
[])
......@@ -564,7 +564,7 @@ class GclientTest(trial_dir.TestCase):
"""Verifies expected behavior of LateOverride."""
url = "git@github.com:dart-lang/spark.git"
d = gclient.Dependency(None, 'name', 'url',
None, None, None, None, None, '', True)
None, None, None, None, '', True)
late_url = d.LateOverride(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