From: Neil Date: Sun, 11 Nov 2012 11:07:51 +0000 (+0200) Subject: Simplfy entrypoint and add files code (both taken from bzr-cia) X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=d5846c47552f312217e200d83c26513063a0b7ee;p=bzrirker.git Simplfy entrypoint and add files code (both taken from bzr-cia) --- diff --git a/__init__.py b/__init__.py index ca1768e..ebbe6c7 100644 --- a/__init__.py +++ b/__init__.py @@ -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(): diff --git a/irkerhook.py b/irkerhook.py index 0f694c8..7e59a6e 100644 --- a/irkerhook.py +++ b/irkerhook.py @@ -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(), }