Commit a5129fb8 authored by maruel@chromium.org's avatar maruel@chromium.org

Fix Checkout.post_processsors setup. __init__() was ignoring the argument!

TEST=Rewrote the unit test to catch that case.

R=dpranke@chromium.org
BUG=

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@89700 0039d316-1c4b-4281-b951-d872f2087c98
parent eba64622
......@@ -65,6 +65,7 @@ class CheckoutBase(object):
post_processor: list of lambda(checkout, patches) to call on each of the
modified files.
"""
super(CheckoutBase, self).__init__()
self.root_dir = root_dir
self.project_name = project_name
if self.project_name is None:
......@@ -73,7 +74,7 @@ class CheckoutBase(object):
self.project_path = os.path.join(self.root_dir, self.project_name)
# Only used for logging purposes.
self._last_seen_revision = None
self.post_processors = None
self.post_processors = post_processors
assert self.root_dir
assert self.project_path
......@@ -159,6 +160,7 @@ class RawCheckout(CheckoutBase):
class SvnConfig(object):
"""Parses a svn configuration file."""
def __init__(self, svn_config_dir=None):
super(SvnConfig, self).__init__()
self.svn_config_dir = svn_config_dir
self.default = not bool(self.svn_config_dir)
if not self.svn_config_dir:
......@@ -241,7 +243,8 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
"""Manages a subversion checkout."""
def __init__(self, root_dir, project_name, commit_user, commit_pwd, svn_url,
post_processors=None):
super(SvnCheckout, self).__init__(root_dir, project_name, post_processors)
CheckoutBase.__init__(self, root_dir, project_name, post_processors)
SvnMixIn.__init__(self)
self.commit_user = commit_user
self.commit_pwd = commit_pwd
self.svn_url = svn_url
......@@ -514,8 +517,9 @@ class GitSvnCheckoutBase(GitCheckoutBase, SvnMixIn):
commit_user, commit_pwd,
svn_url, trunk, post_processors=None):
"""trunk is optional."""
super(GitSvnCheckoutBase, self).__init__(
root_dir, project_name + '.git', remote_branch, post_processors)
GitCheckoutBase.__init__(
self, root_dir, project_name + '.git', remote_branch, post_processors)
SvnMixIn.__init__(self)
self.commit_user = commit_user
self.commit_pwd = commit_pwd
# svn_url in this case is the root of the svn repository.
......@@ -686,6 +690,7 @@ class GitSvnCheckout(GitSvnCheckoutBase):
class ReadOnlyCheckout(object):
"""Converts a checkout into a read-only one."""
def __init__(self, checkout):
super(ReadOnlyCheckout, self).__init__()
self.checkout = checkout
def prepare(self, revision):
......
......@@ -234,9 +234,11 @@ class BaseTest(fake_repos.FakeReposTestBase):
def _log(self):
raise NotImplementedError()
def _test_process(self, co):
def _test_process(self, co_lambda):
"""Makes sure the process lambda is called correctly."""
co.post_processors = [lambda *args: results.append(args)]
post_processors = [lambda *args: results.append(args)]
co = co_lambda(post_processors)
self.assertEquals(post_processors, co.post_processors)
co.prepare(None)
ps = self.get_patches()
results = []
......@@ -395,10 +397,11 @@ class SvnCheckout(SvnBaseTest):
self.assertEquals('LF\n', out)
def testProcess(self):
co = checkout.SvnCheckout(
co = lambda x: checkout.SvnCheckout(
self.root_dir, self.name,
None, None,
self.svn_url)
self.svn_url,
x)
self._test_process(co)
def testPrepare(self):
......@@ -475,10 +478,10 @@ class GitSvnCheckout(SvnBaseTest):
[patch.FilePatchDiff('svn_utils_test.txt', NAKED_PATCH, svn_props)])
def testProcess(self):
co = checkout.SvnCheckout(
co = lambda x: checkout.SvnCheckout(
self.root_dir, self.name,
None, None,
self.svn_url)
self.svn_url, x)
self._test_process(co)
def testPrepare(self):
......@@ -549,10 +552,10 @@ class RawCheckout(SvnBaseTest):
'svn_utils_test.txt.rej\n')
def testProcess(self):
co = checkout.SvnCheckout(
co = lambda x: checkout.SvnCheckout(
self.root_dir, self.name,
None, None,
self.svn_url)
self.svn_url, x)
self._test_process(co)
def testPrepare(self):
......
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