Skip to content

Commit

Permalink
Merge branch 'ticket_338' of git://github.com/gvalkov/buildbot
Browse files Browse the repository at this point in the history
* 'ticket_338' of git://github.com/gvalkov/buildbot:
  Fix typo
  Raise a RuntimeError when the branch from the SourceStamp and defaultBranch are both None.
  Add basic repo/branch/project support (Ticket 338).
  Move compatibility checking out of SVN.startVC

Fixes #338.
  • Loading branch information
Dustin J. Mitchell committed Oct 3, 2010
2 parents 8f4dc94 + fd71df2 commit 6ccd9a9
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 39 deletions.
71 changes: 46 additions & 25 deletions master/buildbot/steps/source.py
Expand Up @@ -494,6 +494,7 @@ class SVN(Source):
"""I perform Subversion checkout/update operations."""

name = 'svn'
branch_placeholder = '%%BRANCH%%'

def __init__(self, svnurl=None, baseURL=None, defaultBranch=None,
directory=None, username=None, password=None,
Expand Down Expand Up @@ -564,11 +565,11 @@ def computeSourceRevision(self, changes):
lastChange = max([int(c.revision) for c in changes])
return lastChange

def startVC(self, branch, revision, patch):
def checkCompatibility(self):
''' Handle compatibility between old slaves/svn clients '''

# handle old slaves
warnings = []
slavever = self.slaveVersion("svn", "old")

if not slavever:
m = "slave does not have the 'svn' command"
raise BuildSlaveTooOldError(m)
Expand Down Expand Up @@ -615,37 +616,57 @@ def startVC(self, branch, revision, patch):
if patch:
raise BuildSlaveTooOldError("old slave can't do patch")

if (self.depth is not None) and self.slaveVersionIsOlderThan("svn","2.9"):
m = ("This buildslave (%s) does not support svn depth "
"arguments. Refusing to build. "
"Please upgrade the buildslave." % (self.build.slavename))
raise BuildSlaveTooOldError(m)

if (self.username is not None or self.password is not None) \
and self.slaveVersionIsOlderThan("svn", "2.8"):
m = ("This buildslave (%s) does not support svn usernames "
"and passwords. "
"Refusing to build. Please upgrade the buildslave to "
"buildbot-0.7.10 or newer." % (self.build.slavename,))
raise BuildSlaveTooOldError(m)

def getSvnUrl(self, branch, revision, patch):
''' Compute the svn url that will be passed to the svn remote command '''
if self.svnurl:
self.args['svnurl'] = self.computeRepositoryURL(self.svnurl)
return self.computeRepositoryURL(self.svnurl)
else:
self.args['svnurl'] = (self.computeRepositoryURL(self.baseURL) +
branch)
if branch is None:
m = ("The SVN source step belonging to builder '%s' does not know "
"which branch to work with. This means that the change source "
"did not specify a branch and that defaultBranch is None." \
% self.build.builder.name)
raise RuntimeError(m)

computed = self.computeRepositoryURL(self.baseURL)

if self.branch_placeholder in self.baseURL:
return computed.replace(self.branch_placeholder, branch)
else:
return computed + branch

def startVC(self, branch, revision, patch):
warnings = []

self.checkCompatibility()

self.args['svnurl'] = self.getSvnUrl(branch, revision, patch)
self.args['revision'] = revision
self.args['patch'] = patch

self.args['always_purge'] = self.always_purge

#Set up depth if specified
if self.depth is not None:
if self.slaveVersionIsOlderThan("svn","2.9"):
m = ("This buildslave (%s) does not support svn depth "
"arguments. Refusing to build. "
"Please upgrade the buildslave." % (self.build.slavename))
raise BuildSlaveTooOldError(m)
else:
self.args['depth'] = self.depth
self.args['depth'] = self.depth

if self.username is not None or self.password is not None:
if self.slaveVersionIsOlderThan("svn", "2.8"):
m = ("This buildslave (%s) does not support svn usernames "
"and passwords. "
"Refusing to build. Please upgrade the buildslave to "
"buildbot-0.7.10 or newer." % (self.build.slavename,))
raise BuildSlaveTooOldError(m)
if self.username is not None:
self.args['username'] = self.username
if self.password is not None:
self.args['password'] = self.password
if self.username is not None:
self.args['username'] = self.username
if self.password is not None:
self.args['password'] = self.password

if self.extra_args is not None:
self.args['extra_args'] = self.extra_args
Expand Down
41 changes: 27 additions & 14 deletions master/docs/cfg-buildsteps.texinfo
Expand Up @@ -522,14 +522,17 @@ should preferentially create the @code{SVN} step with the

@table @code
@item baseURL
(required): this specifies the base repository URL, to which a branch
name will be appended. It should probably end in a slash.
(required): this specifies the base repository URL, to which a branch name will
be appended. Alternatively, @code{baseURL} can contain a @code{%%BRANCH%%}
placeholder, which will be replaced with the branch name. @code{baseURL} should
probably end in a slash.

@item defaultBranch
(optional): this specifies the name of the branch to use when a Build
does not provide one of its own. This is a string that will be
appended to @code{baseURL} to create the URL that will be passed to
the @code{svn checkout} command.
(optional): this specifies the name of the branch to use when a Build does not
provide one of its own. This is a string that will be appended to
@code{baseURL} to create the URL that will be passed to the @code{svn checkout}
command. If you use @code{baseURL} without specifying @code{defaultBranch}
every @code{ChangeStamp} must come with a valid (not None) @code{branch}.

It is possible to mix to have a mix of @code{SVN} steps that use
either the @code{svnurl} or @code{baseURL} arguments but not both at
Expand Down Expand Up @@ -595,7 +598,7 @@ build any of the user branches, but it should be willing to build a
user branch when explicitly requested (most likely by the user who
owns that branch).

There are three things that need to be set up to accomodate this
There are three things that need to be set up to accommodate this
system. The first is a ChangeSource that is capable of identifying the
branch which owns any given file. This depends upon a user-supplied
function, in an external program that runs in the SVN commit hook and
Expand Down Expand Up @@ -651,13 +654,23 @@ c['builders'] = [
]
@end example

In this example, when a change arrives with a @code{branch} attribute
of ``trunk'', the resulting build will have an SVN step that
concatenates ``svn://svn.example.org/MyProject/'' (the baseURL) with
``trunk'' (the branch name) to get the correct svn command. If the
``newthing'' branch has a change to ``src/foo.c'', then the SVN step
will concatenate ``svn://svn.example.org/MyProject/'' with
``features/newthing'' to get the svnurl for checkout.
In this example, when a change arrives with a @code{branch} attribute of
``trunk'', the resulting build will have a SVN step that concatenates
``svn://svn.example.org/MyProject/'' (the baseURL) with ``trunk'' (the branch
name) to get the correct svn command. If the ``newthing'' branch has a change
to ``src/foo.c'', then the SVN step will concatenate
``svn://svn.example.org/MyProject/'' with ``features/newthing'' to get the
svnurl for checkout.

For added flexibility, @code{baseURL} may contain a @code{%%BRANCH%%}
placeholder, which will be replaced either by the branch in the SourceStamp or
the default specified in @code{defaultBranch}.

@example
source.SVN( mode='update',
baseURL='svn://svn.example.org/svn/%%BRANCH%%/myproject',
defaultBranch='trunk' )
@end example

@node Darcs
@subsubsection Darcs
Expand Down

0 comments on commit 6ccd9a9

Please sign in to comment.