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): ...@@ -179,22 +179,26 @@ class DependencySettings(GClientKeywords):
@property @property
def deps_file(self): def deps_file(self):
"""Immutable so no need to lock."""
return self._deps_file return self._deps_file
@property @property
def managed(self): def managed(self):
"""Immutable so no need to lock."""
return self._managed return self._managed
@property @property
def parent(self): def parent(self):
"""Immutable so no need to lock."""
return self._parent 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 @property
def safesync_url(self): def safesync_url(self):
"""Immutable so no need to lock."""
return self._safesync_url return self._safesync_url
@property @property
...@@ -204,18 +208,28 @@ class DependencySettings(GClientKeywords): ...@@ -204,18 +208,28 @@ class DependencySettings(GClientKeywords):
@property @property
def custom_vars(self): def custom_vars(self):
"""Immutable so no need to lock."""
return self._custom_vars.copy() return self._custom_vars.copy()
@property @property
def custom_deps(self): def custom_deps(self):
"""Immutable so no need to lock."""
return self._custom_deps.copy() return self._custom_deps.copy()
@property @property
def url(self): def url(self):
return self._url 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): class Dependency(gclient_utils.WorkItem, DependencySettings):
"""Object that represents a dependency checkout.""" """Object that represents a dependency checkout."""
...@@ -619,21 +633,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -619,21 +633,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
if j.should_process: if j.should_process:
yield j 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 @property
def dependencies(self): def dependencies(self):
return tuple(self._dependencies) return tuple(self._dependencies)
...@@ -695,14 +694,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -695,14 +694,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
i = i.parent i = i.parent
return out 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): class GClient(Dependency):
"""Object that represent a gclient checkout. A tree of Dependency(), one per """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