Skip to content

Commit

Permalink
Take the repository property from the sourcestamp into acount for the…
Browse files Browse the repository at this point in the history
… Source step
  • Loading branch information
Benoit Allard authored and marcus-sonestedt committed Apr 7, 2010
1 parent c5835f4 commit 1a386f2
Showing 1 changed file with 65 additions and 34 deletions.
99 changes: 65 additions & 34 deletions buildbot/steps/source.py
Expand Up @@ -163,6 +163,32 @@ def computeSourceRevision(self, changes):
self.checkoutDelay value."""
return None

def computeRepositoryURL(self, repository):
'''
Helper function thatthe repository URL based on the parameter the

This comment has been minimized.

Copy link
@catlee

catlee Apr 8, 2010

minor typo here

This comment has been minimized.

Copy link
@marcus-sonestedt

marcus-sonestedt Apr 8, 2010

fixed. :)

source step took and the Change 'repository' property
'''

assert not repository or callable(repository) or isinstance(repository, dict) or \
isinstance(repository, str) or isinstance(repository, unicode)

s = self.build.getSourceStamp()
if not repository:
assert s.repository
return s.repository
else:
if callable(repository):
return repository(s.repository)
elif isinstance(repository, dict):
return repository.get(s.repository)
else: # string or unicode
try:
repourl = repository % s.repository
except TypeError:
# that's the backward compatibility case
repourl = repository
return repourl

def start(self):
if self.notReally:
log.msg("faking %s checkout/update" % self.name)
Expand Down Expand Up @@ -228,10 +254,10 @@ def __init__(self, bkurl=None, baseURL=None,
directory=directory,
extra_args=extra_args,
)
if not bkurl and not baseURL:

if bkurl and baseURL:
raise ValueError("you must use exactly one of bkurl and baseURL")


def computeSourceRevision(self, changes):
return changes.revision
Expand All @@ -247,9 +273,9 @@ def startVC(self, branch, revision, patch):

if self.bkurl:
assert not branch # we need baseURL= to use branches
self.args['bkurl'] = self.bkurl
self.args['bkurl'] = self.computeRepositoryURL(self.bkurl)
else:
self.args['bkurl'] = self.baseURL + branch
self.args['bkurl'] = self.computeRepositoryURL(self.baseURL) + branch
self.args['revision'] = revision
self.args['patch'] = patch
self.args['branch'] = branch
Expand Down Expand Up @@ -291,7 +317,7 @@ class CVS(Source):
# parsing each line. Might be handy to have a hook in LogFile that gets
# called with each complete line.

def __init__(self, cvsroot, cvsmodule,
def __init__(self, cvsroot=None, cvsmodule="",
global_options=[], branch=None, checkoutDelay=None,
checkout_options=[],
login=None,
Expand Down Expand Up @@ -356,6 +382,7 @@ def __init__(self, cvsroot, cvsmodule,

self.checkoutDelay = checkoutDelay
self.branch = branch
self.cvsroot = cvsroot

Source.__init__(self, **kwargs)
self.addFactoryArguments(cvsroot=cvsroot,
Expand All @@ -367,8 +394,7 @@ def __init__(self, cvsroot, cvsmodule,
login=login,
)

self.args.update({'cvsroot': cvsroot,
'cvsmodule': cvsmodule,
self.args.update({'cvsmodule': cvsmodule,
'global_options': global_options,
'checkout_options':checkout_options,
'login': login,
Expand Down Expand Up @@ -405,6 +431,7 @@ def startVC(self, branch, revision, patch):

if branch is None:
branch = "HEAD"
self.args['cvsroot'] = self.computeRepositoryURL(self.cvsroot)
self.args['branch'] = branch
self.args['revision'] = revision
self.args['patch'] = patch
Expand Down Expand Up @@ -497,7 +524,7 @@ def __init__(self, svnurl=None, baseURL=None, defaultBranch=None,
depth=depth,
)

if not svnurl and not baseURL:
if svnurl and baseURL:
raise ValueError("you must use exactly one of svnurl and baseURL")


Expand Down Expand Up @@ -560,9 +587,9 @@ def startVC(self, branch, revision, patch):

if self.svnurl:
assert not branch # we need baseURL= to use branches
self.args['svnurl'] = self.svnurl
self.args['svnurl'] = self.computeRepositoryURL(self.svnurl)
else:
self.args['svnurl'] = self.baseURL + branch
self.args['svnurl'] = self.computeRepositoryURL(self.baseURL) + branch
self.args['revision'] = revision
self.args['patch'] = patch

Expand Down Expand Up @@ -649,7 +676,7 @@ def __init__(self, repourl=None, baseURL=None, defaultBranch=None,
)
assert self.args['mode'] != "export", \
"Darcs does not have an 'export' mode"
if (not repourl and not baseURL) or (repourl and baseURL):
if repourl and baseURL:
raise ValueError("you must provide exactly one of repourl and"
" baseURL")

Expand Down Expand Up @@ -682,9 +709,9 @@ def startVC(self, branch, revision, patch):

if self.repourl:
assert not branch # we need baseURL= to use branches
self.args['repourl'] = self.repourl
self.args['repourl'] = self.computeRepositoryURL(self.repourl)
else:
self.args['repourl'] = self.baseURL + branch
self.args['repourl'] = self.computeRepositoryURL(self.baseURL) + branch
self.args['revision'] = revision
self.args['patch'] = patch

Expand All @@ -703,7 +730,7 @@ class Git(Source):

name = "git"

def __init__(self, repourl,
def __init__(self, repourl=None,
branch="master",
submodules=False,
ignore_ignores=None,
Expand All @@ -726,14 +753,14 @@ def __init__(self, repourl,
@param shallow: Use a shallow or clone, if possible
"""
Source.__init__(self, **kwargs)
self.repourl = repourl
self.addFactoryArguments(repourl=repourl,
branch=branch,
submodules=submodules,
ignore_ignores=ignore_ignores,
shallow=shallow,
)
self.args.update({'repourl': repourl,
'branch': branch,
self.args.update({'branch': branch,
'submodules': submodules,
'ignore_ignores': ignore_ignores,
'shallow': shallow,
Expand All @@ -748,6 +775,7 @@ def startVC(self, branch, revision, patch):
if branch is not None:
self.args['branch'] = branch

self.args['repourl'] = self.computeRepositoryURL(self.repourl)
self.args['revision'] = revision
self.args['patch'] = patch
slavever = self.slaveVersion("git")
Expand All @@ -769,7 +797,7 @@ class Arch(Source):
name = "arch"
# TODO: slaves >0.6.6 will accept args['build-config'], so use it

def __init__(self, url, version, archive=None, **kwargs):
def __init__(self, url=None, version=None, archive=None, **kwargs):
"""
@type url: string
@param url: the Arch coordinates of the repository. This is
Expand All @@ -787,14 +815,14 @@ def __init__(self, url, version, archive=None, **kwargs):
repository's default will be used.
"""
self.branch = version
self.url = url
Source.__init__(self, **kwargs)
self.addFactoryArguments(url=url,
version=version,
archive=archive,
)
self.args.update({'url': url,
'archive': archive,
})
assert version, "version should be provided"
self.args.update({'archive': archive})

def computeSourceRevision(self, changes):
# in Arch, fully-qualified revision numbers look like:
Expand Down Expand Up @@ -858,6 +886,7 @@ def checkSlaveVersion(self, cmd, branch):
return warnings

def startVC(self, branch, revision, patch):
self.args['url'] = self.computeRepositoryURL(self.url),
self.args['version'] = branch
self.args['revision'] = revision
self.args['patch'] = patch
Expand Down Expand Up @@ -898,16 +927,17 @@ def __init__(self, url, version, archive, **kwargs):
archive.
"""
self.branch = version
self.url = url
Source.__init__(self, **kwargs)
self.addFactoryArguments(url=url,
version=version,
archive=archive,
)
self.args.update({'url': url,
'archive': archive,
self.args.update({'archive': archive,
})

def startVC(self, branch, revision, patch):
self.args['url'] = self.computeRepositoryURL(url),
self.args['version'] = branch
self.args['revision'] = revision
self.args['patch'] = patch
Expand Down Expand Up @@ -972,7 +1002,7 @@ def __init__(self, repourl=None, baseURL=None, defaultBranch=None,
forceSharedRepo=forceSharedRepo
)
self.args.update({'forceSharedRepo': forceSharedRepo})
if (not repourl and not baseURL) or (repourl and baseURL):
if repourl and baseURL:
raise ValueError("you must provide exactly one of repourl and"
" baseURL")

Expand All @@ -990,9 +1020,9 @@ def startVC(self, branch, revision, patch):

if self.repourl:
assert not branch # we need baseURL= to use branches
self.args['repourl'] = self.repourl
self.args['repourl'] = self.computeRepositoryURL(self.repourl)
else:
self.args['repourl'] = self.baseURL + branch
self.args['repourl'] = self.computeRepositoryURL(self.baseURL) + branch
self.args['revision'] = revision
self.args['patch'] = patch

Expand Down Expand Up @@ -1060,7 +1090,7 @@ def __init__(self, repourl=None, baseURL=None, defaultBranch=None,
branchType=branchType,
clobberOnBranchChange=clobberOnBranchChange,
)
if (not repourl and not baseURL) or (repourl and baseURL):
if repourl and baseURL:
raise ValueError("you must provide exactly one of repourl and"
" baseURL")

Expand All @@ -1073,11 +1103,11 @@ def startVC(self, branch, revision, patch):
if self.repourl:
# we need baseURL= to use dirname branches
assert self.branchType == 'inrepo' or not branch
self.args['repourl'] = self.repourl
self.args['repourl'] = self.computeRepositoryURL(self.repourl)
if branch:
self.args['branch'] = branch
else:
self.args['repourl'] = self.baseURL + (branch or '')
self.args['repourl'] = self.computeRepositoryURL(self.baseURL) + (branch or '')
self.args['revision'] = revision
self.args['patch'] = patch
self.args['clobberOnBranchChange'] = self.clobberOnBranchChange
Expand Down Expand Up @@ -1110,7 +1140,7 @@ class P4(Source):
""" P4 is a class for accessing perforce revision control"""
name = "p4"

def __init__(self, p4base, defaultBranch=None, p4port=None, p4user=None,
def __init__(self, p4base=None, defaultBranch=None, p4port=None, p4user=None,
p4passwd=None, p4extra_views=[],
p4client='buildbot_%(slave)s_%(builder)s', **kwargs):
"""
Expand Down Expand Up @@ -1156,7 +1186,7 @@ def __init__(self, p4base, defaultBranch=None, p4port=None, p4user=None,
self.args['p4port'] = p4port
self.args['p4user'] = p4user
self.args['p4passwd'] = p4passwd
self.args['p4base'] = p4base
self.args['p4base'] = self.computeRepositoryURL(p4base)
self.args['p4extra_views'] = p4extra_views
self.p4client = p4client

Expand Down Expand Up @@ -1240,7 +1270,7 @@ class Monotone(Source):

name = "monotone"

def __init__(self, server_addr, branch, db_path="monotone.db",
def __init__(self, server_addr=None, branch=None, db_path="monotone.db",
monotone="monotone",
**kwargs):
Source.__init__(self, **kwargs)
Expand All @@ -1249,8 +1279,8 @@ def __init__(self, server_addr, branch, db_path="monotone.db",
db_path=db_path,
monotone=monotone,
)
self.args.update({"server_addr": server_addr,
"branch": branch,
assert branch, "branch must be specified"
self.args.update({"branch": branch,
"db_path": db_path,
"monotone": monotone})

Expand All @@ -1260,6 +1290,7 @@ def computeSourceRevision(self, changes):
return changes[-1].revision

def startVC(self):
self.args["server_addr"] = self.computeRepositoryURL(server_addr),
slavever = self.slaveVersion("monotone")
assert slavever, "slave is too old, does not know about monotone"
cmd = LoggedRemoteCommand("monotone", self.args)
Expand Down

0 comments on commit 1a386f2

Please sign in to comment.