[Buildbot-devel] Changing the behavior of the SVN buildstep defaultBranch argument...

Marc-Antoine Ruel maruel at chromium.org
Fri Mar 26 18:25:47 UTC 2010


@param password: username to pass to svn's --password

that's cute

I don't mind personally but I'd probably rewrite the last hunk as:

if ((self.branch and self.branch != 'trunk') or
        (self.branch is None and branch != 'trunk')):
    revstuff.append("[branch]")


2010/3/26 Gareth Armstrong <gareth.armstrong at hp.com>:
> Hello All,
>
> I would like to get some feedback on a proposed change in behavior for the
> SVN buildstep's defaultBranch argument.
>
> Here is the context, at work we have a SVN repo similar to that hosted by
> the Apache foundation http://svn.apache.org/repos/asf/.  A parent repo
> hosting many submodules, each with a typical SVN structure of branches, tags
> and trunk.
>
> Due to the setup of the project that I am developing a BuildBot config for,
> I would like to do something like this.
>
> steps = []
> # Do a sparse checkout to a directory that will host later checkouts
> s = SVN(baseURL='%s' % self.project['vcs_baseurl'],
>         defaultBranch='',   # NOTE, I don't want to grab anything specific
> just a revision
>         mode='update',
>         workdir='build/svn/HOLDER',
>         depth='empty',
>         haltOnFailure=True)
> steps.append(s)
>
> # Checkout a trunk module to the above HOLDER directory
> s = SVN(baseURL='%s%s/' % (self.project['vcs_baseurl'], 'buildtools'),
>         defaultBranch='trunk',
>         mode='update',
>         workdir='build/svn/HOLDER/buildtools',
>         haltOnFailure=True)
> steps.append(s)
>
> # Checkout another module from the 1.xx branch to the above HOLDER directory
> s = SVN(baseURL='%s%s/' % (self.project['vcs_baseurl'], 'TOTO'),
>         defaultBranch='branches/1.xx',
>         mode='update',
>         workdir='build/svn/HOLDER/TOTO,
>         haltOnFailure=True)
> steps.append(s)
> return steps
>
> This all works fine as long as you are on the SVN "trunk" i.e. "branch =
> None".  Once you begin working on a SVN branch this falls down as branch
> overrides the defaultBranch argument of the SVN buildstep. Therefore I
> customized the SVN source step to get the behavior that I expect even when
> we are on a branch.
>
> Would folks like to see this become the default, or should legacy preside?
> Thoughts and comments are more than welcome.  If feedback is positive I will
> post a patch to github.  In any case, have a good weekend
>
> All the best,
>
> Gareth
>
> In any case, details below.
>
>
> --- /home/gareth/WORK/git/buildbot/buildbot/steps/source.py    2010-03-23
> 09:52:42.729221546 +0100
> +++ source.py    2010-03-26 18:12:20.058471232 +0100
> @@ -452,22 +452,28 @@
>                         alternate branches: use C{baseURL} to enable this.
>                         Use exactly one of C{svnurl} and C{baseURL}.
>
> +        @type  baseURL: string
>          @param baseURL: if branches are enabled, this is the base URL to
>                          which a branch name will be appended. It should
>                          probably end in a slash. Use exactly one of
>                          C{svnurl} and C{baseURL}.
>
> -        @param defaultBranch: if branches are enabled, this is the branch
> -                              to use if the Build does not specify one
> +        @type  defaultBranch: string or None
> +        @param defaultBranch: if specified this overrides the branch
> +                              to use during a Build, even if branches
> +                              are enabled and the Build specifies one
>                                explicitly. It will simply be appended
>                                to C{baseURL} and the result handed to
>                                the SVN command.
>
> +        @type  username: string
>          @param username: username to pass to svn's --username
> +
> +        @type  password: string
>          @param password: username to pass to svn's --password
>          """
>
> -        if not kwargs.has_key('workdir') and directory is not None:
> +        if not 'workdir' in kwargs and directory is not None:
>              # deal with old configs
>              warn("Please use workdir=, not directory=", DeprecationWarning)
>              kwargs['workdir'] = directory
> @@ -494,13 +500,12 @@
>                                   keep_on_purge=keep_on_purge,
>                                   ignore_ignores=ignore_ignores,
>                                   always_purge=always_purge,
> -                 depth=depth,
> +                                 depth=depth,
>                                   )
>
>          if not svnurl and not baseURL:
>              raise ValueError("you must use exactly one of svnurl and
> baseURL")
>
> -
>      def computeSourceRevision(self, changes):
>          if not changes or None in [c.revision for c in changes]:
>              return None
> @@ -508,7 +513,6 @@
>          return lastChange
>
>      def startVC(self, branch, revision, patch):
> -
>          # handle old slaves
>          warnings = []
>          slavever = self.slaveVersion("svn", "old")
> @@ -563,6 +567,14 @@
>              self.args['svnurl'] = self.svnurl
>          else:
>              self.args['svnurl'] = self.baseURL + branch
> +            # If we declare defaultBranch it should override the branch
> +            # specified by the Build when branches are enabled.
> +            if branch and (branch != self.branch and self.branch is not
> None):
> +                m = ('Overriding Build branch "%s" with defaultBranch '
> +                     'value "%s"' % (branch, self.branch))
> +                log.msg(m)
> +                self.args['svnurl'] = self.baseURL + self.branch
> +
>          self.args['revision'] = revision
>          self.args['patch'] = patch
>
> @@ -572,11 +584,11 @@
>          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))
> +                     "arguments.  "
> +                     "Refusing to build. "
> +                     "Please upgrade the buildslave." %
> (self.build.slavename))
>                  raise BuildSlaveTooOldError(m)
> -            else:
> +            else:
>                  self.args['depth'] = self.depth
>
>          if self.username is not None or self.password is not None:
> @@ -586,15 +598,24 @@
>                       "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
>
>          revstuff = []
> -        if branch is not None and branch != self.branch:
> +        #revstuff.append("branch=%s" % branch)
> +        #revstuff.append("self.branch=%s" % self.branch)
> +        if branch is not None or branch != self.branch:
>              revstuff.append("[branch]")
> +            if self.branch is None and branch == 'trunk':
> +                revstuff.remove("[branch]")
> +            if self.branch == 'trunk':
> +                revstuff.remove("[branch]")
> +
>          if revision is not None:
>              revstuff.append("r%s" % revision)
>          if patch is not None:
>
> --
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
>
>


More information about the devel mailing list