1
# -.- coding: utf-8 -.-
5
# Copyright © 2009 Markus Korn <thekorn@gmx.de>
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Lesser General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Lesser General Public License for more details.
17
# You should have received a copy of the GNU Lesser General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
"""Post-commit hook to submit the commit to Zeitgeist (http://www.zeitgeist-project.com)
22
Requires bzr 0.15 or higher.
24
Copyright (C) 2009, Markus Korn <thekorn@gmx.de>
25
Published under the GNU GPLv2 or later
28
Copy this directory to ~/.bazaar/plugins/zeitgeist/*
33
from bzrlib import branch
35
logging.basicConfig(filename="/dev/null")
39
from zeitgeist import dbusutils
40
IFACE = dbusutils.get_engine_interface()
41
except: # FIXME: adjust this to ImportError, whatever exception is raised
42
# as the fix for LP: #397432
46
def post_commit(local, master, old_revno, old_revid, new_revno, new_revid):
47
revision = master.repository.get_revision(new_revid)
53
"timestamp": int(time.time()),
54
"uri": unicode(master.base),
55
"text": unicode(revision.message),
56
"source": "Bzr Branch",
58
"use": u"http://gnome.org/zeitgeist/schema/1.0/core#%s" %use,
59
"mimetype": u"application/x-bzr-branch",
62
"app": u"/usr/share/applications/olive-gtk.desktop",
63
"origin": u"", # we are not sure about the origin of this item,
64
# let's make it NULL, it has to be a string
66
items = [dbusutils.plainify_dict(item),]
67
IFACE.InsertEvents(items)
70
branch.Branch.hooks.install_named_hook("post_commit", post_commit,
71
"Zeitgeist dataprovider for bzr")