Commit 8c0d9582 authored by maruel@chromium.org's avatar maruel@chromium.org

Move more immutable members to DependencySettings.

Helps figuring out what is mutable and what is not.
The goal is to shorten the class Dependency to reduce places where mutations can occur.

R=dpranke@chromium.org
BUG=
TEST=


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@103782 0039d316-1c4b-4281-b951-d872f2087c98
parent ed102570
......@@ -179,22 +179,26 @@ class DependencySettings(GClientKeywords):
@property
def deps_file(self):
"""Immutable so no need to lock."""
return self._deps_file
@property
def managed(self):
"""Immutable so no need to lock."""
return self._managed
@property
def parent(self):
"""Immutable so no need to lock."""
return self._parent
@property
def root(self):
"""Returns the root node, a GClient object."""
if not self.parent:
# This line is to signal pylint that it could be a GClient instance.
return self or GClient(None, None)
return self.parent.root
@property
def safesync_url(self):
"""Immutable so no need to lock."""
return self._safesync_url
@property
......@@ -204,18 +208,28 @@ class DependencySettings(GClientKeywords):
@property
def custom_vars(self):
"""Immutable so no need to lock."""
return self._custom_vars.copy()
@property
def custom_deps(self):
"""Immutable so no need to lock."""
return self._custom_deps.copy()
@property
def url(self):
return self._url
@property
def recursion_limit(self):
"""Returns > 0 if this dependency is not too recursed to be processed."""
return max(self.parent.recursion_limit - 1, 0)
def get_custom_deps(self, name, url):
"""Returns a custom deps if applicable."""
if self.parent:
url = self.parent.get_custom_deps(name, url)
# None is a valid return value to disable a dependency.
return self.custom_deps.get(name, url)
class Dependency(gclient_utils.WorkItem, DependencySettings):
"""Object that represents a dependency checkout."""
......@@ -619,21 +633,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
if j.should_process:
yield j
def get_custom_deps(self, name, url):
"""Returns a custom deps if applicable."""
if self.parent:
url = self.parent.get_custom_deps(name, url)
# None is a valid return value to disable a dependency.
return self.custom_deps.get(name, url)
@property
def recursion_limit(self):
"""Returns > 0 if this dependency is not too recursed to be processed.
Immutable so no need to lock.
"""
return max(self.parent.recursion_limit - 1, 0)
@property
def dependencies(self):
return tuple(self._dependencies)
......@@ -695,14 +694,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
i = i.parent
return out
@property
def root(self):
"""Returns the root node, a GClient object."""
if not self.parent:
# This line is to signal pylint that it could be a GClient instance.
return self or GClient(None, None)
return self.parent.root
class GClient(Dependency):
"""Object that represent a gclient checkout. A tree of Dependency(), one per
......
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