Commit 4bdd5fd5 authored by maruel@chromium.org's avatar maruel@chromium.org

Move dependencies to a (to be) locked property.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/7982005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@102777 0039d316-1c4b-4281-b951-d872f2087c98
parent 8ac2b27f
...@@ -203,9 +203,6 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings): ...@@ -203,9 +203,6 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings):
def __init__(self, parent, name, url, safesync_url, managed, custom_deps, def __init__(self, parent, name, url, safesync_url, managed, custom_deps,
custom_vars, deps_file, should_process): custom_vars, deps_file, should_process):
# Warning: this function can be called from any thread. Both
# self.dependencies and self.requirements are read and modified from
# multiple threads at the same time. Sad.
GClientKeywords.__init__(self) GClientKeywords.__init__(self)
gclient_utils.WorkItem.__init__(self, name) gclient_utils.WorkItem.__init__(self, name)
DependencySettings.__init__( DependencySettings.__init__(
...@@ -219,7 +216,7 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings): ...@@ -219,7 +216,7 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings):
# Calculates properties: # Calculates properties:
self.parsed_url = None self.parsed_url = None
self.dependencies = [] self._dependencies = []
# A cache of the files affected by the current operation, necessary for # A cache of the files affected by the current operation, necessary for
# hooks. # hooks.
self._file_list = [] self._file_list = []
...@@ -438,7 +435,7 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings): ...@@ -438,7 +435,7 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings):
# Convert the deps into real Dependency. # Convert the deps into real Dependency.
for name, url in deps.iteritems(): for name, url in deps.iteritems():
if name in [s.name for s in self.dependencies]: if name in [s.name for s in self._dependencies]:
raise gclient_utils.Error( raise gclient_utils.Error(
'The same name "%s" appears multiple times in the deps section' % 'The same name "%s" appears multiple times in the deps section' %
name) name)
...@@ -456,8 +453,10 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings): ...@@ -456,8 +453,10 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings):
raise gclient_utils.Error( raise gclient_utils.Error(
'Dependency %s specified more than once:\n %s\nvs\n %s' % 'Dependency %s specified more than once:\n %s\nvs\n %s' %
(name, tree[name].hierarchy(), self.hierarchy())) (name, tree[name].hierarchy(), self.hierarchy()))
self.dependencies.append(Dependency(self, name, url, None, None, None, self._dependencies.append(
None, self.deps_file, should_process)) Dependency(
self, name, url, None, None, None, None,
self.deps_file, should_process))
logging.debug('Loaded: %s' % str(self)) logging.debug('Loaded: %s' % str(self))
# Arguments number differs from overridden method # Arguments number differs from overridden method
...@@ -638,7 +637,10 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings): ...@@ -638,7 +637,10 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem, DependencySettings):
return max(self.parent.recursion_limit - 1, 0) return max(self.parent.recursion_limit - 1, 0)
@property @property
@gclient_utils.lockedmethod def dependencies(self):
return tuple(self._dependencies)
@property
def file_list(self): def file_list(self):
result = self._file_list[:] result = self._file_list[:]
for d in self.dependencies: for d in self.dependencies:
...@@ -761,7 +763,7 @@ solutions = [ ...@@ -761,7 +763,7 @@ solutions = [
if s['name'] in tree: if s['name'] in tree:
raise gclient_utils.Error( raise gclient_utils.Error(
'Dependency %s specified more than once in .gclient' % s['name']) 'Dependency %s specified more than once in .gclient' % s['name'])
self.dependencies.append(Dependency( self._dependencies.append(Dependency(
self, s['name'], s['url'], self, s['name'], s['url'],
s.get('safesync_url', None), s.get('safesync_url', None),
s.get('managed', True), s.get('managed', True),
......
...@@ -134,7 +134,8 @@ class GclientTest(trial_dir.TestCase): ...@@ -134,7 +134,8 @@ class GclientTest(trial_dir.TestCase):
# The trick here is to manually process the list to make sure it's out of # The trick here is to manually process the list to make sure it's out of
# order. # order.
for i in obj.dependencies: for i in obj.dependencies:
i.dependencies.sort(key=lambda x: x.name, reverse=reverse) # pylint: disable=W0212
i._dependencies.sort(key=lambda x: x.name, reverse=reverse)
actual = self._get_processed() actual = self._get_processed()
# We don't care of the ordering of these items: # We don't care of the ordering of these items:
self.assertEquals( self.assertEquals(
...@@ -209,22 +210,22 @@ class GclientTest(trial_dir.TestCase): ...@@ -209,22 +210,22 @@ class GclientTest(trial_dir.TestCase):
parser = gclient.Parser() parser = gclient.Parser()
options, _ = parser.parse_args([]) options, _ = parser.parse_args([])
obj = gclient.GClient('foo', options) obj = gclient.GClient('foo', options)
obj.dependencies.append( obj._dependencies.append(
gclient.Dependency(obj, 'foo', 'url', None, None, None, None, 'DEPS', gclient.Dependency(obj, 'foo', 'url', None, None, None, None, 'DEPS',
True)) True))
obj.dependencies.append( obj._dependencies.append(
gclient.Dependency(obj, 'bar', 'url', None, None, None, None, 'DEPS', gclient.Dependency(obj, 'bar', 'url', None, None, None, None, 'DEPS',
True)) True))
obj.dependencies[0].dependencies.append( obj.dependencies[0]._dependencies.append(
gclient.Dependency( gclient.Dependency(
obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None, obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None,
'DEPS', True)) 'DEPS', True))
obj.dependencies[0].dependencies.append( obj.dependencies[0]._dependencies.append(
gclient.Dependency( gclient.Dependency(
obj.dependencies[0], 'foo/dir2', obj.dependencies[0], 'foo/dir2',
gclient.GClientKeywords.FromImpl('bar'), None, None, None, None, gclient.GClientKeywords.FromImpl('bar'), None, None, None, None,
'DEPS', True)) 'DEPS', True))
obj.dependencies[0].dependencies.append( obj.dependencies[0]._dependencies.append(
gclient.Dependency( gclient.Dependency(
obj.dependencies[0], 'foo/dir3', obj.dependencies[0], 'foo/dir3',
gclient.GClientKeywords.FileImpl('url'), None, None, None, None, gclient.GClientKeywords.FileImpl('url'), None, None, None, 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