[Buildbot-devel] got_revision Build Property (w/ PATCH!)

Oz oz at santacruzgames.com
Fri Mar 23 19:52:53 UTC 2007


Hello again,

So, I tracked down the problem myself, it was a bug in buildbot in 
buildbot.slave.commands.SVN. Observe a snippet from parseGotRevision:

     def _parse(res):
         r = c.stdout.strip()
         got_version = None
         try:
             got_version = int(r)
         except ValueError:
             msg =("SVN.parseGotRevision unable to parse output "
                   "of svnversion: '%s'" % r)
             log.msg(msg)
             self.sendStatus({'header': msg + "\n"})
         return got_version

This function parses the output from "svnversion ." on a working copy. 
However, it assume that the stdout can always be converted to an int. 
svnversion can legally return all sorts of stuff. In addition to the 
plain revision number (for unmodified working copies), it can also 
return stuff like (this is from the --help):

4123:4168     mixed revision working copy
4168M         modified working copy
4123S         switched working copy
4123:4168MS   mixed revision, modified, switched working copy

In my case, I had a modified working copy with the extra "M" at the end 
since my build process ends up modifying some files. Then the next build 
for an update builder would parse a version number like "4168M" and not 
be able to convert it to an int.

So my fix is to simply strip the "M" or "S" if it's there. A more robust 
fix would deal with all the cases, but I'm not sure what "got_revision" 
should be for mixed copies.

Anyways, the patch is attached. "patch -p1 -i got-revision.patch" inside 
a pristine 0.7.5 directory should do the trick. Hope it makes it into 
0.7.6...

=oz

Oz wrote:
> Hello list,
> 
> I'm attempting to implement a step in my build process that copies the 
> entire project's output directory over onto a network drive for general 
> developer consumption. Naturally, I'd like to dynamically name this 
> directory r3456 (or whatever my SVN repository version may be). I am 
> using the 'got_revision' build properties to fetch this number in the 
> build step since that should work with build triggered by 
> PBChangeSource, Nightly schedulers, and forced builds.
> 
> The relevant sections of my master.cfg are as follows:
> 
> ------------------------------------
> # Custom build step for copying a directory on Windows
> class CopyDirectory(ShellCommand):
>    name = 'directory copy'
>    haltOnFailure = 0
>    description = ['copying directory']
>    descriptionDone = ['directory copied']
> 
>    def __init__(self, source, dest, **kwargs):
>      ShellCommand.__init__(self, **kwargs)
>      self.command = ['MKDIR', dest, '&&', 'COPY', '%s\\*.*'%source, dest]
> 
> builder['factory'].addStep(CopyDirectory, source = 'bin\\ds\\cw\\fin',
>    dest = WithProperties('\\\\server\\project_x\\BUILDS\\Auto\\r%d\\', 
> 'got_revision'))
> ------------------------------------
> 
> Occasionally when I restart my buildmaster and re-create buildslaves 
> from scratch, this approach will work. However, the vast majority of the 
> time, 'got_revision' (using SVN) is interpolated to an empty string, 
> which of course, causes a TypeError exception when it tries to shove an 
> empty string into a %d format string.
> 
> I was under the impression from the docs that 'got_revision' would 
> always return an integer for SVN repositories.
> 
> Any ideas what's going on here?
> 
> Thank you.
> 
> =oz
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
> 
> 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: got-revision.patch
URL: <http://buildbot.net/pipermail/devel/attachments/20070323/45445ab2/attachment.ksh>


More information about the devel mailing list