Commit efc80931 authored by nsylvain@google.com's avatar nsylvain@google.com

Add a --deps-file flag to gclient to allow using a deps file other than DEPS.

TEST=covered by gclient_smoketest.py
Review URL: http://codereview.chromium.org/7062029

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@87367 0039d316-1c4b-4281-b951-d872f2087c98
parent 9842a0c7
......@@ -138,7 +138,6 @@ class GClientKeywords(object):
class Dependency(GClientKeywords, gclient_utils.WorkItem):
"""Object that represents a dependency checkout."""
DEPS_FILE = 'DEPS'
def __init__(self, parent, name, url, safesync_url, custom_deps,
custom_vars, deps_file, should_process):
......@@ -154,7 +153,7 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
self.custom_deps = custom_deps or {}
self.deps_hooks = []
self.dependencies = []
self.deps_file = deps_file or self.DEPS_FILE
self.deps_file = deps_file
# A cache of the files affected by the current operation, necessary for
# hooks.
self._file_list = []
......@@ -266,7 +265,8 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
}
filepath = os.path.join(self.root_dir(), self.name, self.deps_file)
if not os.path.isfile(filepath):
logging.info('%s: No DEPS file found at %s' % (self.name, filepath))
logging.info('%s: No %s file found at %s' % (self.name, self.deps_file,
filepath))
else:
deps_content = gclient_utils.FileRead(filepath)
logging.debug(deps_content)
......@@ -331,7 +331,7 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
'Dependency %s specified more than once:\n %s\nvs\n %s' %
(name, tree[name].hierarchy(), self.hierarchy()))
self.dependencies.append(Dependency(self, name, url, None, None, None,
None, should_process))
self.deps_file, should_process))
logging.debug('Loaded: %s' % str(self))
# Arguments number differs from overridden method
......@@ -585,6 +585,7 @@ class GClient(Dependency):
solutions = [
{ "name" : "%(solution_name)s",
"url" : "%(solution_url)s",
"deps_file" : "%(deps_file)s",
"custom_deps" : {
},
"safesync_url": "%(safesync_url)s",
......@@ -595,6 +596,7 @@ solutions = [
DEFAULT_SNAPSHOT_SOLUTION_TEXT = ("""\
{ "name" : "%(solution_name)s",
"url" : "%(solution_url)s",
"deps_file" : "%(deps_file)s",
"custom_deps" : {
%(solution_deps)s },
"safesync_url": "%(safesync_url)s",
......@@ -611,7 +613,8 @@ 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, None, None, None, True)
Dependency.__init__(self, None, None, None, None, None, None, 'unused',
True)
self._options = options
if options.deps_os:
enforced_os = options.deps_os.split(',')
......@@ -642,7 +645,7 @@ solutions = [
s.get('safesync_url', None),
s.get('custom_deps', {}),
s.get('custom_vars', {}),
None,
s.get('deps_file', 'DEPS'),
True))
except KeyError:
raise gclient_utils.Error('Invalid .gclient file. Solution is '
......@@ -668,10 +671,12 @@ solutions = [
os.path.join(path, options.config_filename)))
return client
def SetDefaultConfig(self, solution_name, solution_url, safesync_url):
def SetDefaultConfig(self, solution_name, deps_file, solution_url,
safesync_url):
self.SetConfig(self.DEFAULT_CLIENT_FILE_TEXT % {
'solution_name': solution_name,
'solution_url': solution_url,
'deps_file': deps_file,
'safesync_url' : safesync_url,
})
......@@ -846,6 +851,7 @@ solutions = [
new_gclient += self.DEFAULT_SNAPSHOT_SOLUTION_TEXT % {
'solution_name': d.name,
'solution_url': d.url,
'deps_file': d.deps_file,
'safesync_url' : d.safesync_url or '',
'solution_deps': ''.join(custom_deps),
}
......@@ -964,6 +970,11 @@ URL.
'probably can\'t contain any newlines.')
parser.add_option('--name',
help='overrides the default name for the solution')
parser.add_option('--deps-file', default='DEPS',
help='overrides the default name for the DEPS file for the'
'main solutions and all sub-dependencies')
parser.add_option('--git-deps', action='store_true',
help='sets the deps file to ".DEPS.git" instead of "DEPS"')
(options, args) = parser.parse_args(args)
if ((options.spec and args) or len(args) > 2 or
(not options.spec and not args)):
......@@ -982,10 +993,13 @@ URL.
else:
# specify an alternate relpath for the given URL.
name = options.name
deps_file = options.deps_file
if options.git_deps:
deps_file = '.DEPS.git'
safesync_url = ''
if len(args) > 1:
safesync_url = args[1]
client.SetDefaultConfig(name, base_url, safesync_url)
client.SetDefaultConfig(name, deps_file, base_url, safesync_url)
client.SaveConfig()
return 0
......
......@@ -433,7 +433,7 @@ class FakeRepos(FakeReposBase):
'-q', '--non-interactive', '--no-auth-cache',
'--username', self.USERS[0][0], '--password', self.USERS[0][1]])
assert os.path.isdir(join(self.svn_checkout, '.svn'))
def file_system(rev, DEPS):
def file_system(rev, DEPS, DEPS_ALT=None):
fs = {
'origin': 'svn@%(rev)d\n',
'trunk/origin': 'svn/trunk@%(rev)d\n',
......@@ -447,6 +447,8 @@ class FakeRepos(FakeReposBase):
for k in fs.iterkeys():
fs[k] = fs[k] % { 'rev': rev }
fs['trunk/src/DEPS'] = DEPS
if DEPS_ALT:
fs['trunk/src/DEPS.alt'] = DEPS_ALT
return fs
# Testing:
......@@ -462,7 +464,7 @@ class FakeRepos(FakeReposBase):
# TODO(maruel):
# - $matching_files
# - use_relative_paths
fs = file_system(1, """
DEPS = """
vars = {
'DummyVariable': 'third_party',
}
......@@ -474,7 +476,15 @@ deps_os = {
'mac': {
'src/third_party/prout': '/trunk/third_party/prout',
},
}""" % { 'svn_base': self.svn_base })
}""" % { 'svn_base': self.svn_base }
DEPS_ALT = """
deps = {
'src/other2': '%(svn_base)strunk/other@2'
}
""" % { 'svn_base': self.svn_base }
fs = file_system(1, DEPS, DEPS_ALT)
self._commit_svn(fs)
fs = file_system(2, """
......
......@@ -199,6 +199,7 @@ class GClientSmoke(GClientSmokeBase):
('solutions = [\n'
' { "name" : "src",\n'
' "url" : "%strunk/src",\n'
' "deps_file" : "DEPS",\n'
' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
......@@ -209,6 +210,7 @@ class GClientSmoke(GClientSmokeBase):
('solutions = [\n'
' { "name" : "src",\n'
' "url" : "%srepo_1",\n'
' "deps_file" : "DEPS",\n'
' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
......@@ -219,12 +221,24 @@ class GClientSmoke(GClientSmokeBase):
'solutions = [\n'
' { "name" : "foo",\n'
' "url" : "foo",\n'
' "deps_file" : "DEPS",\n'
' "custom_deps" : {\n'
' },\n'
' "safesync_url": "faa",\n'
' },\n'
']\n')
test(['config', 'foo', '--deps', 'blah'],
'solutions = [\n'
' { "name" : "foo",\n'
' "url" : "foo",\n'
' "deps_file" : "blah",\n'
' "custom_deps" : {\n'
' },\n'
' "safesync_url": "",\n'
' },\n'
']\n')
test(['config', '--spec', '["blah blah"]'], '["blah blah"]')
os.remove(p)
......@@ -672,6 +686,7 @@ class GClientSmokeSVN(GClientSmokeBase):
'solutions = [\n'
' { "name" : "src",\n'
' "url" : "%(base)s/src",\n'
' "deps_file" : "DEPS",\n'
' "custom_deps" : {\n'
' "foo/bar": None,\n'
' "invalid": None,\n'
......@@ -686,6 +701,28 @@ class GClientSmokeSVN(GClientSmokeBase):
{ 'base': self.svn_base + 'trunk' })
self.check((out, '', 0), results)
def testRevInfoAltDeps(self):
if not self.enabled:
return
self.gclient(['config', self.svn_base + 'trunk/src/', '--deps-file',
'DEPS.alt'])
self.gclient(['sync'])
results = self.gclient(['revinfo', '--snapshot'])
out = ('# Snapshot generated with gclient revinfo --snapshot\n'
'solutions = [\n'
' { "name" : "src",\n'
' "url" : "%(base)s/src",\n'
' "deps_file" : "DEPS.alt",\n'
' "custom_deps" : {\n'
' "src/other2": \'%(base)s/other@2\',\n'
' },\n'
' "safesync_url": "",\n'
' },\n'
']\n\n' %
{ 'base': self.svn_base + 'trunk' })
self.check((out, '', 0), results)
def testWrongDirectory(self):
# Check that we're not using a .gclient configuration which only talks
# about a subdirectory src when we're in a different subdirectory src-other.
......
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