Package buildbot :: Package changes :: Module manager
[frames] | no frames]

Source Code for Module buildbot.changes.manager

  1  # ***** BEGIN LICENSE BLOCK ***** 
  2  # Version: MPL 1.1/GPL 2.0/LGPL 2.1 
  3  # 
  4  # The contents of this file are subject to the Mozilla Public License Version 
  5  # 1.1 (the "License"); you may not use this file except in compliance with 
  6  # the License. You may obtain a copy of the License at 
  7  # http://www.mozilla.org/MPL/ 
  8  # 
  9  # Software distributed under the License is distributed on an "AS IS" basis, 
 10  # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 11  # for the specific language governing rights and limitations under the 
 12  # License. 
 13  # 
 14  # The Original Code is Mozilla-specific Buildbot steps. 
 15  # 
 16  # The Initial Developer of the Original Code is 
 17  # Mozilla Foundation. 
 18  # Portions created by the Initial Developer are Copyright (C) 2009 
 19  # the Initial Developer. All Rights Reserved. 
 20  # 
 21  # Contributor(s): 
 22  #   Brian Warner <warner@lothar.com> 
 23  # 
 24  # Alternatively, the contents of this file may be used under the terms of 
 25  # either the GNU General Public License Version 2 or later (the "GPL"), or 
 26  # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 
 27  # in which case the provisions of the GPL or the LGPL are applicable instead 
 28  # of those above. If you wish to allow use of your version of this file only 
 29  # under the terms of either the GPL or the LGPL, and not to allow others to 
 30  # use your version of this file under the terms of the MPL, indicate your 
 31  # decision by deleting the provisions above and replace them with the notice 
 32  # and other provisions required by the GPL or the LGPL. If you do not delete 
 33  # the provisions above, a recipient may use your version of this file under 
 34  # the terms of any one of the MPL, the GPL or the LGPL. 
 35  # 
 36  # ***** END LICENSE BLOCK ***** 
 37   
 38  from zope.interface import implements 
 39  from twisted.python import log 
 40  from twisted.internet import defer 
 41  from twisted.application import service 
 42   
 43  from buildbot import interfaces, util 
 44   
45 -class ChangeManager(service.MultiService):
46 47 """This is the master-side service which receives file change 48 notifications from a VCS. It keeps a log of these changes, enough to 49 provide for the HTML waterfall display, and to tell 50 temporarily-disconnected bots what they missed while they were 51 offline. 52 53 Change notifications come from two different kinds of sources. The first 54 is a PB service (servicename='changemaster', perspectivename='change'), 55 which provides a remote method called 'addChange', which should be 56 called with a dict that has keys 'filename' and 'comments'. 57 58 The second is a list of objects derived from the 59 L{buildbot.changes.base.ChangeSource} class. These are added with 60 .addSource(), which also sets the .changemaster attribute in the source 61 to point at the ChangeMaster. When the application begins, these will 62 be started with .start() . At shutdown time, they will be terminated 63 with .stop() . They must be persistable. They are expected to call 64 self.changemaster.addChange() with Change objects. 65 66 There are several different variants of the second type of source: 67 68 - L{buildbot.changes.mail.MaildirSource} watches a maildir for CVS 69 commit mail. It uses DNotify if available, or polls every 10 70 seconds if not. It parses incoming mail to determine what files 71 were changed. 72 73 - L{buildbot.changes.freshcvs.FreshCVSSource} makes a PB 74 connection to the CVSToys 'freshcvs' daemon and relays any 75 changes it announces. 76 77 """ 78 79 implements(interfaces.IEventSource) 80 81 changeHorizon = 0 82 name = "changemanager" 83
84 - def __init__(self):
85 service.MultiService.__init__(self) 86 self._cache = util.LRUCache()
87
88 - def addSource(self, source):
89 assert interfaces.IChangeSource.providedBy(source) 90 assert service.IService.providedBy(source) 91 source.setServiceParent(self)
92
93 - def removeSource(self, source):
94 assert source in self 95 return defer.maybeDeferred(source.disownServiceParent)
96
97 - def addChange(self, change):
98 """Deliver a file change event. The event should be a Change object. 99 This method will timestamp the object as it is received.""" 100 log.msg("adding change, who %s, %d files, rev=%s, branch=%s, repository=%s, " 101 "comments %s, category %s" % (change.who, len(change.files), 102 change.revision, change.branch, change.repository, 103 change.comments, change.category)) 104 105 #self.pruneChanges() # use self.changeHorizon 106 # for now, add these in the background, without waiting for it. TODO: 107 # return a Deferred. 108 #self.queue.add(db.runInteraction, self.addChangeToDatabase, change) 109 110 # this sets change.number, if it wasn't already set (by the 111 # migration-from-pickle code). It also fires a notification which 112 # wakes up the Schedulers. 113 self.parent.addChange(change)
114 115 116 # IEventSource methods 117
118 - def eventGenerator(self, branches=[], categories=[], committers=[], minTime=0):
119 return self.parent.db.changeEventGenerator(branches, categories, 120 committers, minTime)
121
122 - def getChangeNumberedNow(self, changeid, t=None):
123 return self.parent.db.getChangeNumberedNow(changeid, t)
124 - def getChangeByNumber(self, changeid):
125 return self.parent.db.getChangeByNumber(changeid)
126 - def getChangesGreaterThan(self, last_changeid, t=None):
127 return self.parent.db.getChangesGreaterThan(last_changeid, t)
128 - def getChangesByNumber(self, changeids):
129 return self.parent.db.getChangesByNumber(changeids)
130 - def getLatestChangeNumberNow(self, t=None):
131 return self.parent.db.getLatestChangeNumberNow(t)
132