Skip to content

Commit

Permalink
Merge branch 'compute-repository-url-multirepo' of git://github.com/t…
Browse files Browse the repository at this point in the history
…omprince/buildbot

* 'compute-repository-url-multirepo' of git://github.com/tomprince/buildbot:
  Fix _ComputeRepositoryURL for multirepo support.
  • Loading branch information
djmitche committed May 19, 2012
2 parents dffbdc2 + 0464a04 commit d430153
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
31 changes: 16 additions & 15 deletions master/buildbot/steps/source/oldsource.py
Expand Up @@ -26,7 +26,8 @@
class _ComputeRepositoryURL(object):
implements(IRenderable)

def __init__(self, repository):
def __init__(self, step, repository):
self.step = step
self.repository = repository

def getRenderingFor(self, props):
Expand All @@ -37,7 +38,7 @@ def getRenderingFor(self, props):

build = props.getBuild()
assert build is not None, "Build should be available *during* a build?"
s = build.getSourceStamp('') # TODO: use correct codebase
s = build.getSourceStamp(self.step.codebase)

repository = self.repository

Expand Down Expand Up @@ -160,7 +161,7 @@ def __init__(self, cvsroot=None, cvsmodule="",

self.checkoutDelay = checkoutDelay
self.branch = branch
self.cvsroot = _ComputeRepositoryURL(cvsroot)
self.cvsroot = _ComputeRepositoryURL(self, cvsroot)

Source.__init__(self, **kwargs)

Expand Down Expand Up @@ -287,8 +288,8 @@ def __init__(self, svnurl=None, baseURL=None, defaultBranch=None,
warn("Please use workdir=, not directory=", DeprecationWarning)
kwargs['workdir'] = directory

self.svnurl = svnurl and _ComputeRepositoryURL(svnurl)
self.baseURL = _ComputeRepositoryURL(baseURL)
self.svnurl = svnurl and _ComputeRepositoryURL(self, svnurl)
self.baseURL = _ComputeRepositoryURL(self, baseURL)
self.branch = defaultBranch
self.username = username
self.password = password
Expand Down Expand Up @@ -439,8 +440,8 @@ def __init__(self, repourl=None, baseURL=None, defaultBranch=None,
C{baseURL} and the result handed to the
'darcs pull' command.
"""
self.repourl = _ComputeRepositoryURL(repourl)
self.baseURL = _ComputeRepositoryURL(baseURL)
self.repourl = _ComputeRepositoryURL(self, repourl)
self.baseURL = _ComputeRepositoryURL(self, baseURL)
self.branch = defaultBranch
Source.__init__(self, **kwargs)
assert self.args['mode'] != "export", \
Expand Down Expand Up @@ -535,7 +536,7 @@ def __init__(self, repourl=None,
lack of output, but requires Git 1.7.2+.
"""
Source.__init__(self, **kwargs)
self.repourl = _ComputeRepositoryURL(repourl)
self.repourl = _ComputeRepositoryURL(self, repourl)
self.branch = branch
self.args.update({'submodules': submodules,
'ignore_ignores': ignore_ignores,
Expand Down Expand Up @@ -604,7 +605,7 @@ def __init__(self,
"""
Source.__init__(self, **kwargs)
self.manifest_url = _ComputeRepositoryURL(manifest_url)
self.manifest_url = _ComputeRepositoryURL(self, manifest_url)
self.args.update({'manifest_branch': manifest_branch,
'manifest_file': manifest_file,
'tarball': tarball,
Expand Down Expand Up @@ -744,8 +745,8 @@ def __init__(self, repourl=None, baseURL=None, defaultBranch=None,
if not using update/copy mode, or if using
update/copy mode with multiple branches.
"""
self.repourl = _ComputeRepositoryURL(repourl)
self.baseURL = _ComputeRepositoryURL(baseURL)
self.repourl = _ComputeRepositoryURL(self, repourl)
self.baseURL = _ComputeRepositoryURL(self, baseURL)
self.branch = defaultBranch
Source.__init__(self, **kwargs)
self.args.update({'forceSharedRepo': forceSharedRepo})
Expand Down Expand Up @@ -827,8 +828,8 @@ def __init__(self, repourl=None, baseURL=None, defaultBranch=None,
at each branch change. Otherwise, just
update to the branch.
"""
self.repourl = _ComputeRepositoryURL(repourl)
self.baseURL = _ComputeRepositoryURL(baseURL)
self.repourl = _ComputeRepositoryURL(self, repourl)
self.baseURL = _ComputeRepositoryURL(self, baseURL)
self.branch = defaultBranch
self.branchType = branchType
self.clobberOnBranchChange = clobberOnBranchChange
Expand Down Expand Up @@ -921,7 +922,7 @@ def __init__(self, p4base=None, defaultBranch=None, p4port=None, p4user=None,
@param p4client: The perforce client to use for this buildslave.
"""

self.p4base = _ComputeRepositoryURL(p4base)
self.p4base = _ComputeRepositoryURL(self, p4base)
self.branch = defaultBranch
Source.__init__(self, **kwargs)
self.args['p4port'] = p4port
Expand Down Expand Up @@ -1023,7 +1024,7 @@ def __init__(self, repourl=None, branch=None, progress=False, **kwargs):
lack of output.
"""
Source.__init__(self, **kwargs)
self.repourl = _ComputeRepositoryURL(repourl)
self.repourl = _ComputeRepositoryURL(self, repourl)
if (not repourl):
raise ValueError("you must provide a repository uri in 'repourl'")
if (not branch):
Expand Down
Expand Up @@ -37,20 +37,23 @@ def render(self, value):
self.props.build = self
return defer.maybeDeferred(IRenderable(value).getRenderingFor, self.props)

class FakeStep(object):
codebase = ''

class RepoURL(unittest.TestCase):
def setUp(self):
self.build = Build()

def test_backward_compatibility(self):
url = _ComputeRepositoryURL("repourl")
url = _ComputeRepositoryURL(FakeStep(), "repourl")
d = self.build.render(url)
@d.addCallback
def callback(res):
self.assertEquals(res, "repourl")
return d

def test_format_string(self):
url = _ComputeRepositoryURL("http://server/%s")
url = _ComputeRepositoryURL(FakeStep(), "http://server/%s")
d = self.build.render(url)
@d.addCallback
def callback(res):
Expand All @@ -60,7 +63,7 @@ def callback(res):
def test_dict(self):
dict = {}
dict['test'] = "ssh://server/testrepository"
url = _ComputeRepositoryURL(dict)
url = _ComputeRepositoryURL(FakeStep(), dict)
d = self.build.render(url)
@d.addCallback
def callback(res):
Expand All @@ -69,15 +72,15 @@ def callback(res):

def test_callable(self):
func = lambda x: x[::-1]
url = _ComputeRepositoryURL(func)
url = _ComputeRepositoryURL(FakeStep(), func)
d = self.build.render(url)
@d.addCallback
def callback(res):
self.assertEquals(res, "tset")
return d

def test_backward_compatibility_render(self):
url = _ComputeRepositoryURL(WithProperties("repourl%(foo)s"))
url = _ComputeRepositoryURL(FakeStep(), WithProperties("repourl%(foo)s"))
d = self.build.render(url)
@d.addCallback
def callback(res):
Expand All @@ -86,7 +89,7 @@ def callback(res):

def test_dict_render(self):
d = dict(test=WithProperties("repourl%(foo)s"))
url = _ComputeRepositoryURL(d)
url = _ComputeRepositoryURL(FakeStep(), d)
d = self.build.render(url)
@d.addCallback
def callback(res):
Expand All @@ -95,7 +98,7 @@ def callback(res):

def test_callable_render(self):
func = lambda x: WithProperties(x+"%(foo)s")
url = _ComputeRepositoryURL(func)
url = _ComputeRepositoryURL(FakeStep(), func)
d = self.build.render(url)
@d.addCallback
def callback(res):
Expand Down

0 comments on commit d430153

Please sign in to comment.