changeset 169:8e656a659ffa

timestamp
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 31 Jan 2011 18:22:01 -0800
parents 8528311427e0
children 274d7dc787e3
files autobot/changes/poller.py
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/autobot/changes/poller.py	Mon Jan 31 18:18:38 2011 -0800
+++ b/autobot/changes/poller.py	Mon Jan 31 18:22:01 2011 -0800
@@ -436,3 +436,31 @@
             return changes.split()
         d.addCallback(split_changes)
         return d
+
+    ### metadata for commits
+
+    ### timestamp
+
+    def _get_commit_timestamp(self, rev):
+        # unix timestamp
+        args = ['log', rev, '--no-walk', r'--format=%ct']
+        d = utils.getProcessOutput(self.binary, args, path=self.workdir,
+                                   env=dict(PATH=os.environ['PATH']),
+                                   errortoo=False )
+        d.addCallback(self._get_commit_timestamp_from_output)
+        return d
+
+    def _get_commit_timestamp_from_output(self, output):
+        stripped_output = output.strip()
+        if self.usetimestamps:
+            try:
+                stamp = float(stripped_output)
+            except Exception, e:
+                    self.log('caught exception converting output \'%s\' to timestamp' % stripped_output)
+                    raise e
+            self.commitInfo['timestamp'] = stamp
+        else:
+            self.commitInfo['timestamp'] = None
+        return self.commitInfo['timestamp'] # for tests
+
+    ### commit author ('name')