[Buildbot-commits] buildbot/buildbot/changes changes.py,1.19,1.20

Brian Warner warner at users.sourceforge.net
Sat Apr 23 10:22:12 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/changes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24338/buildbot/changes

Modified Files:
	changes.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-73
Creator:  Brian Warner <warner at monolith.lothar.com>

clean up ChangeSource handling

2005-04-23  Brian Warner  <warner at lothar.com>

   * buildbot/changes/changes.py: import defer, oops
   (ChangeMaster): remove the .sources list, rely upon the fact that
   MultiServices can be treated as sequences of their children. This
   cleans up the add/remove ChangeSource routines a lot, as we keep
   exactly one list of the current sources instead of three.

   * buildbot/master.py (BuildMaster.__init__): remove .sources, set
   up an empty ChangeMaster at init time.
   (BuildMaster.loadChanges): if there are changes to be had from
   disk, replace self.change_svc with the new ones. If not, keep
   using the empty ChangeMaster set up in __init__.
   (BuildMaster.loadConfig_Sources): use list(self.change_svc)
   instead of a separate list, makes the code a bit cleaner.
   * buildbot/test/test_config.py (ConfigTest.testSimple): match it
   (ConfigTest.testSources): same, also wait for loadConfig to finish.
   Extend the test to make sure we can get rid of the sources when
   we're done.


Index: changes.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/changes/changes.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- changes.py	22 Apr 2005 21:29:19 -0000	1.19
+++ changes.py	23 Apr 2005 10:22:10 -0000	1.20
@@ -8,6 +8,7 @@
     import pickle
 
 from twisted.python import log, components
+from twisted.internet import defer
 from twisted.spread import pb
 from twisted.application import service
 from twisted.cred import portal
@@ -157,7 +158,7 @@
     
     """
 
-    debug = 0
+    debug = False
     # todo: use Maildir class to watch for changes arriving by mail
 
     def __init__(self):
@@ -166,7 +167,6 @@
         # self.basedir must be filled in by the parent
         # self.botmaster too
         self.nextNumber = 1
-        self.sources = [] # for status page: what sources are being monitored
 
     def addSource(self, source):
         assert components.implements(source, interfaces.IChangeSource)
@@ -174,13 +174,12 @@
         if self.debug:
             print "ChangeMaster.addSource", source
         source.setServiceParent(self)
-        self.sources.append(source)
 
     def removeSource(self, source):
+        assert source in self
         if self.debug:
-            print "ChangeMaster.removeSource", source
+            print "ChangeMaster.removeSource", source, source.parent
         d = defer.maybeDeferred(source.disownServiceParent)
-        self.sources.remove(source)
         return d
 
     def addChange(self, change):
@@ -226,14 +225,12 @@
         del d['services'] # lose all children
         del d['namedServices']
         del d['botmaster']
-        del d['sources']
         return d
 
     def __setstate__(self, d):
         self.__dict__ = d
         # self.basedir must be set by the parent
         # self.botmaster too
-        self.sources = [] # will be filled when the config file is read
         self.services = [] # they'll be repopulated by readConfig
         self.namedServices = {}
 





More information about the Commits mailing list