changeset 166:dba6bcae1575

* removal of some excessive logging * more stubbing of our very own GitPoller
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 31 Jan 2011 17:51:30 -0800
parents 6396220f937e
children f603922dd5c8
files autobot/changes/poller.py
diffstat 1 files changed, 47 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/autobot/changes/poller.py	Mon Jan 31 17:05:54 2011 -0800
+++ b/autobot/changes/poller.py	Mon Jan 31 17:51:30 2011 -0800
@@ -111,6 +111,9 @@
         d.addCallback(log_finished)
         return d
 
+    def log(self, msg):
+        log.msg('%s: %s' % (self.name, msg))
+
     def describe(self):
         status = ""
         if not self.parent:
@@ -121,6 +124,7 @@
 
     def poll(self):
         """poll for new changes"""
+        
         d = self._get_changes()
         d.addCallback(self._process_changes)
         d.addErrback(self._process_changes_failure)
@@ -132,22 +136,22 @@
 
     def _setPreHash(self, _hash):
         self.preHash = _hash.strip()
-        log.msg("preHash is %s" % self.preHash)
+        self.log("preHash is %s" % self.preHash)
 
     def _setPostHash(self, _hash):
         self.postHash = _hash.strip()
-        log.msg("postHash is %s" % self.postHash)
+        self.log("postHash is %s" % self.postHash)
 
     def _get_changes(self):
         """update the changes if the hash doesnt match"""
 
         self.lastPoll = time.time()
-        log.msg('%s: polling repo at %s : %s' % (self.name, self.repourl, self.lastPoll))
+        self.log('polling repo at %s : %s' % (self.name, self.repourl, self.lastPoll))
 
         d = defer.succeed(None)
         # ensure the repository is initialized
         if not self.isInitialized():
-            log.msg('Initialing new repository')
+            self.log('Initialing new repository')
             d.addCallback(self.initRepository)
 
         # get the hash before updating
@@ -166,6 +170,7 @@
     ### functions related to processing changes
 
     def _process_changes(self, _):
+        """processes the changes between the preHash and the postHash"""
 
         d = defer.succeed(None)
 
@@ -180,16 +185,14 @@
 
     def _process_change_list(self, revList):
 
-        log.msg('this is the changelist: %s' % revList)
         self.changeCount = len(revList)
-        log.msg('%s: processing %d changes: %s in "%s"'
-                % (self.name, self.changeCount, revList, self.workdir) )
+        self.log('processing %d changes: %s in "%s"'
+                 % (self.changeCount, revList, self.workdir) )
 
         # get metadata for changes and send them to master
         d = defer.succeed(None)
         for rev in revList:
             d.addCallback(self._process_change, rev)
-
         return d
 
     def _process_change(self, something, rev):
@@ -257,7 +260,11 @@
         return os.path.exists(os.path.join(self.workdir, '.hg'))
 
     def initializationCommands(self):
-        return [ [ 'clone', self.repourl, self.workdir ] ]
+        commands = [ [ 'clone', self.repourl, self.workdir ] ]
+        if self.branch != 'default':
+            # TODO
+            pass
+        return commands
 
     def _fetch(self, _):
 
@@ -273,6 +280,7 @@
 
 
     def _hash(self, _):
+        """commit hash"""
         d = utils.getProcessOutput(self.binary, ['tip', '--template', '{node}\\n'],
                                    path=self.workdir,
                                    env=dict(PATH=os.environ['PATH']), errortoo=False )
@@ -386,3 +394,33 @@
     def isInitialized(self):
         """is the repository initialized?"""
         return os.path.exists(os.path.join(self.workdir, '.git'))
+
+    def initializationCommands(self):
+        """commands needed to initialize the repository"""
+        
+        commands = [ [ 'clone', self.repourl, self.workdir ] ]
+        if self.branch != 'master':
+            commands.append(['checkout', self.branch])
+        return commands
+
+    def _fetch(self, _):
+        args = ['pull', 'origin', self.branch]
+        d = utils.getProcessOutput(self.binary, args, path=self.workdir,
+                                   env=dict(PATH=os.environ['PATH']),
+                                   errortoo=True)
+        return d
+
+    def _hash(self, _):
+        """
+        get hash of where you are now:
+        git show-ref HEAD --hash
+        """
+        
+        d = utils.getProcessOutput(self.binary, ['show-ref', 'HEAD', '--hash'],
+                                   path=self.workdir,
+                                   env=dict(PATH=os.environ['PATH']), errortoo=False )
+        return d
+
+    def _change_list(self, _):
+        range = '%s..%s' % (self.preHash, self.postHash)
+        # TODO: finish!