Ticket #296: schedulersUseNotify.diff

File schedulersUseNotify.diff, 4.2 kB (added by bhearsum, 6 months ago)

[v3] enable schedulers to use buildset notification

  • a/buildbot/scheduler.py

    old new  
    4646        # TODO: why can't id() return a positive number? %d is ugly. 
    4747        return "<Scheduler '%s' at %d>" % (self.name, id(self)) 
    4848 
    49     def submitBuildSet(self, bs): 
    50         self.parent.submitBuildSet(bs
     49    def submitBuildSet(self, bs, notifyScheduler=None): 
     50        self.parent.submitBuildSet(bs, notifyScheduler
    5151 
    5252    def addChange(self, change): 
    5353        pass 
     
    5555class BaseUpstreamScheduler(BaseScheduler): 
    5656    implements(interfaces.IUpstreamScheduler) 
    5757 
    58     def __init__(self, name, properties={}): 
     58    def __init__(self, name, properties={}, notifyScheduler=None): 
    5959        BaseScheduler.__init__(self, name, properties) 
    6060        self.successWatchers = [] 
     61        self.notifyScheduler = notifyScheduler 
    6162 
    6263    def subscribeToSuccessfulBuilds(self, watcher): 
    6364        self.successWatchers.append(watcher) 
     
    6768    def submitBuildSet(self, bs): 
    6869        d = bs.waitUntilFinished() 
    6970        d.addCallback(self.buildSetFinished) 
    70         BaseScheduler.submitBuildSet(self, bs
     71        BaseScheduler.submitBuildSet(self, bs, self.notifyScheduler
    7172 
    7273    def buildSetFinished(self, bss): 
    7374        if not self.running: 
     
    8889 
    8990    fileIsImportant = None 
    9091    compare_attrs = ('name', 'treeStableTimer', 'builderNames', 'branch', 
    91                      'fileIsImportant', 'properties'
     92                     'fileIsImportant', 'properties', 'notifyScheduler'
    9293     
    9394    def __init__(self, name, branch, treeStableTimer, builderNames, 
    94                  fileIsImportant=None, properties={}): 
     95                 fileIsImportant=None, properties={}, notifyScheduler=None): 
    9596        """ 
    9697        @param name: the name of this Scheduler 
    9798        @param branch: The branch name that the Scheduler should pay 
     
    118119                           scheduler 
    119120        """ 
    120121 
    121         BaseUpstreamScheduler.__init__(self, name, properties
     122        BaseUpstreamScheduler.__init__(self, name, properties, notifyScheduler
    122123        self.treeStableTimer = treeStableTimer 
    123124        errmsg = ("The builderNames= argument to Scheduler must be a list " 
    124125                  "of Builder description names (i.e. the 'name' key of the " 
     
    210211    fileIsImportant = None 
    211212 
    212213    compare_attrs = ('name', 'branches', 'treeStableTimer', 'builderNames', 
    213                      'fileIsImportant', 'properties'
     214                     'fileIsImportant', 'properties', 'notifyScheduler'
    214215 
    215216    def __init__(self, name, branches, treeStableTimer, builderNames, 
    216                  fileIsImportant=None, properties={}): 
     217                 fileIsImportant=None, properties={}, notifyScheduler=None): 
    217218        """ 
    218219        @param name: the name of this Scheduler 
    219220        @param branches: The branch names that the Scheduler should pay 
     
    260261        if fileIsImportant: 
    261262            assert callable(fileIsImportant) 
    262263            self.fileIsImportant = fileIsImportant 
     264        self.notifyScheduler = notifyScheduler 
    263265        self.schedulers = {} # one per branch 
    264266 
    265267    def __repr__(self): 
     
    289291            s = self.schedulerFactory(name, branch, 
    290292                                      self.treeStableTimer, 
    291293                                      self.builderNames, 
    292                                       self.fileIsImportant) 
     294                                      self.fileIsImportant, 
     295                                      notifyScheduler=self.notifyScheduler) 
    293296            s.successWatchers = self.successWatchers 
    294297            s.setServiceParent(self) 
    295298            # TODO: does this result in schedulers that stack up forever? 
    296299            # When I make the persistify-pass, think about this some more. 
    297300            self.schedulers[branch] = s 
    298301        s.addChange(change) 
     302 
     303    # for some reason, the unittests don't pass unless AnyBranchScheduler has 
     304    # this method. if BaseUpstreamScheduler is modified in this way, they still 
     305    # fail. i suspect it has something to do with me not understanding 
     306    # twisted services enough 
     307    def submitBuildSet(self, bs, junk): 
     308        BaseUpstreamScheduler.submitBuildSet(self, bs) 
    299309 
    300310 
    301311class Dependent(BaseUpstreamScheduler):