changeset 113:5fd588ba6ff9

trying with a silly deferred list
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 22 Jan 2011 17:56:27 -0800
parents 5b26c2d4710e
children 60e307e74829
files autobot/changes/poller.py
diffstat 1 files changed, 8 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/autobot/changes/poller.py	Sat Jan 22 17:50:48 2011 -0800
+++ b/autobot/changes/poller.py	Sat Jan 22 17:56:27 2011 -0800
@@ -118,14 +118,15 @@
         return str
 
     def poll(self):
+        """poll for new changes"""
         d = self._get_changes()
         d.addCallback(self._process_changes)
         d.addErrback(self._process_changes_failure)
         d.addCallback(self._catch_up)
         d.addErrback(self._catch_up_failure)
-        return d
+        return d    
 
-    
+    ### functions relating to hashing
 
     def _setPreHash(self, _hash):
         self.preHash = _hash.strip()
@@ -135,7 +136,6 @@
         self.postHash = _hash.strip()
         log.msg("The *NEW* secret key is %s" % self.postHash)
 
-#    @defer.deferredGenerator
     def _get_changes(self):
         """update the changes if the hash doesnt match"""
 
@@ -146,7 +146,6 @@
         # ensure the repository is initialized
         if not self.isInitialized():
             log.msg('Initialing new repository')
-#            d = self.initRepository()
             d.addCallback(self.initRepository)
 
         # get the hash before updating
@@ -163,25 +162,9 @@
         
         return d
 
-#         wfd = defer.waitForDeferred(d)
-#         yield wfd
-#         results = wfd.getResult()
-#         self.preHash = results.strip()
-#         log.msg('prehash = %s' % self.preHash)
+    ### functions related to processing changes
 
-#         # get a deferred object that performs the fetch
-#         yield self._fetch()
-        
-#         # get the hash after updating
-#         d = self._hash()
-#         wfd = defer.waitForDeferred(d)
-#         yield wfd
-#         results = wfd.getResult()
-#         self.postHash = results.strip()
-
-
-#    @defer.deferredGenerator
-    def _process_changes(self, unused_output):
+    def _process_changes(self, _):
 
         d = defer.succeed(None)
 
@@ -202,7 +185,7 @@
                 % (self.name, self.changeCount, revList, self.workdir) )
 
         # get metadata for changes and send them to master
-        d = defer.succeed(None)
+        _dl = []
         for rev in revList:
             self.commitInfo = {}
 
@@ -216,7 +199,8 @@
 
             # add the change, apparently
             dl.addCallback(self._add_change, rev)
-            d.addCallback(dl)
+            _dl.append(_dl)
+        return defer.DeferredList(_dl)
         return d
 
     def _add_change(self, change):