Simplfy entrypoint and add files code (both taken from bzr-cia)
authorNeil <neil@dip.sun.ac.za>
Sun, 11 Nov 2012 11:07:51 +0000 (13:07 +0200)
committerNeil <neil@dip.sun.ac.za>
Sun, 11 Nov 2012 11:07:51 +0000 (13:07 +0200)
__init__.py
irkerhook.py

index ca1768e45974a038c8c4f297352aa85c4df057a4..ebbe6c775a2686cdc5e25ec509f7d2453b1b41f5 100644 (file)
@@ -17,25 +17,25 @@ from bzrlib.plugins.bzrirker import irkerhook as _irkerhook
 """)
 
 
-def post_commit(branch, revision_id):
-    """This is the post_commit hook that should get run after commit."""
-    _irkerhook.IrkerSender(branch, revision_id,
-            branch.get_config_stack()).send_maybe()
-
 
 def branch_commit_hook(local, master, old_revno, old_revid,
         new_revno, new_revid):
     """This is the post_commit hook that runs after commit."""
-    _irkerhook.IrkerSender(master, new_revid, master.get_config_stack(),
-                         local_branch=local).send_maybe()
+    if local is None:
+        _irkerhook.IrkerSender(master, new_revid,
+                master.get_config_stack()).send()
+    else:
+        _irkerhook.IrkerSender(local, new_revid,
+                master.get_config_stack()).send()
 
 
 def branch_post_change_hook(params):
     """This is the post_change_branch_tip hook."""
     # (branch, old_revno, new_revno, old_revid, new_revid)
-    _irker.IrkerSender(params.branch, params.new_revid,
-        params.branch.get_config_stack(), local_branch=None,
-        op='change').send_maybe()
+    br = params.branch
+    revs = br.revision_history()[params.old_revno:params.new_revno]
+    for rev_id in revs:
+        _irker.IrkerSender(br, rev_id, br.get_config_stack()).send()
 
 
 def test_suite():
index 0f694c8f15e910cfe87ecfead10ca58337a4b488..7e59a6ebc767d63fe371c169d166982e886e40d9 100644 (file)
@@ -21,30 +21,32 @@ import json
 class IrkerSender(object):
     """An irker message sender."""
 
-    def __init__(self, branch, revision_id, config, local_branch=None,
-        op='commit'):
+    def __init__(self, branch, revision_id, config):
         self.config = config
         self.branch = branch
         self.repository = branch.repository
-        if (local_branch is not None and
-            local_branch.repository.has_revision(revision_id)):
-            self.repository = local_branch.repository
         self._revision_id = revision_id
         self.revision = None
         self.revno = None
-        self.op = op
 
     def _setup_revision_and_revno(self):
         self.revision = self.repository.get_revision(self._revision_id)
         self.revno = self.branch.revision_id_to_revno(self._revision_id)
 
     def _format(self):
+        delta = self.branch.repository.get_revision_delta(self._revision_id)
+        files = []
+        [files.append(f) for (f,_,_) in delta.added]
+        [files.append(f) for (f,_,_) in delta.removed]
+        [files.append(f) for (_,f,_,_,_,_) in delta.renamed]
+        [files.append(f) for (f,_,_,_,_) in delta.modified]
+
         fields = {
             'project': self.project(),
             'committer': self.revision.committer,
-            'repo': '',
+            'repo': self.branch.nick,
             'rev': '%d' % self.revno,
-            'files': '',
+            'files': ' '.join(files),
             'logmsg': self.revision.get_summary(),
             'url': self.url(),
         }