author Ben Hearsum <>
Mon, 06 Dec 2010 12:07:23 -0500
changeset 108 87f34291e31d2f49f394e63e404c768211b5a080
parent 62 4215d71b01e61298be864d348ec7936425abc8d0
permissions -rw-r--r--
Create buildbot-0.7 branch

from buildbot.process import base
from buildbot.status import builder
from import Properties

class BuildSet:
    """I represent a set of potential Builds, all of the same source tree,
    across a specified list of Builders. I can represent a build of a
    specific version of the source tree (named by source.branch and
    source.revision), or a build of a certain set of Changes

    def __init__(self, builderNames, source, reason=None, bsid=None,
        @param source: a L{buildbot.sourcestamp.SourceStamp}
        self.builderNames = builderNames
        self.source = source
        self.reason = reason = Properties()
        if properties:

        self.stillHopeful = True
        self.status = bss = builder.BuildSetStatus(source, reason,
                                                   builderNames, bsid)

    def waitUntilSuccess(self):
        return self.status.waitUntilSuccess()
    def waitUntilFinished(self):
        return self.status.waitUntilFinished()

    def start(self, builders):
        """This is called by the BuildMaster to actually create and submit
        the BuildRequests."""
        self.requests = []
        reqs = []

        # create the requests
        for b in builders:
            req = base.BuildRequest(self.reason, self.source,, 
            reqs.append((b, req))
            d = req.waitUntilFinished()
            d.addCallback(self.requestFinished, req)

        # tell our status about them
        req_statuses = [req.status for req in self.requests]

        # now submit them
        for b,req in reqs:

    def requestFinished(self, buildstatus, req):
        # TODO: this is where individual build status results are aggregated
        # into a BuildSet-wide status. Consider making a rule that says one
        # WARNINGS results in the overall status being WARNINGS too. The
        # current rule is that any FAILURE means FAILURE, otherwise you get
        # SUCCESS.
        results = buildstatus.getResults()
        if results == builder.FAILURE:
            if self.stillHopeful:
                # oh, cruel reality cuts deep. no joy for you. This is the
                # first failure. This flunks the overall BuildSet, so we can
                # notify success watchers that they aren't going to be happy.
                self.stillHopeful = False
        if not self.requests:
            # that was the last build, so we can notify finished watchers. If
            # we haven't failed by now, we can claim success.
            if self.stillHopeful: