Merge lp:~manishsinha/zeitgeist-datasources/bzr-improvements-subjects into lp:zeitgeist-datasources/0.8

Status: Merged
Merged at revision: 173
Proposed branch: lp:~manishsinha/zeitgeist-datasources/bzr-improvements-subjects
Merge into: lp:zeitgeist-datasources/0.8
Diff against target: 350 lines (+220/-100)
3 files modified
bzr/Makefile.am (+2/-1)
bzr/__init__.py (+13/-99)
bzr/hooks.py (+205/-0)
To merge this branch: bzr merge lp:~manishsinha/zeitgeist-datasources/bzr-improvements-subjects
Reviewer Review Type Date Requested Status
Seif Lotfy Pending
Michal Hruby Pending
Jelmer Vernooij Pending
Zeitgeist Data-Sources Team Pending
Review via email: mp+99168@code.launchpad.net

Description of the change

Fixed the subjects

* Actor is bzr.desktop just so that we are able to fetch the events
* Apart from folder subject, added subject for each file involved in the event
* Used Gio.File to get the mimetype of the file subject
* Subject Interpretation is not being set as it is decided by the mimetype
* File subjects are set only for commit messages as for push and pull, remote URI are
    used from which mimetype cannot be found out by Gio.File
* In case of Commit the text is "Revision: 23, Message: commit message"
* In case of Push, commit message is like "Pushed branch from 12 to 14"
* In case of Pull, commit message is like "Updated branch from 12 to 14"

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks for hacking on this.

Some comments:

Using "is_push" with three different values is quite confusing to wrap your head around, especially as it can have the values False, True and None. Wouldn't it be better to just have a "change_kind" argument that can be set to "commit", "push" or "pull" ?

The other subjects shouldn't be set if there is no working tree (in that case the files don't exist on disk).

I think the other subjects should only be set in the case of push and pull, and not in the case of commit as commit doesn't actually change those files.

It would make sense to add a post_merge hook too. Merge/revert affects the files in the tree too, although it doesn't have any affect on the branch (unlike push/pull and commit). Perhaps that can wait for another branch though.

Revision history for this message
Michal Hruby (mhr3) wrote :

You're using USER_ACTIVITY in all cases, but if I just pull, all the changed files definitely aren't changed by the user, so that's clearly wrong.

+1 on the is_push misusage.

All in all I'm not really sure what to think of this dataprovider, more data is good (I guess), but whenever you really work with any of the files from the repo, you're using an editor. I can't shake off the feeling we're trying to somehow duplicate what the VCS system does itself - keep a commit log.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> You're using USER_ACTIVITY in all cases, but if I just pull, all the changed files definitely aren't changed by the user, so
> that's clearly wrong.
The action is triggered by the user though, it's not an external action. If the user downloads a file from elsewhere onto the local system, then isn't that still USER_ACTIVTITY, even if the user didn't write the (entire) file?

> All in all I'm not really sure what to think of this dataprovider, more data is good (I guess), but whenever you really work
> with any of the files from the repo, you're using an editor. I can't shake off the feeling we're trying to somehow duplicate
> what the VCS system does itself - keep a commit log.
That's true - though it's more like a tiplog. In other words, this records the changes to the tip of this particular branch, rather than the actual history. If the current branch updates from revision 10 to revision 30, then that's a single change here, not 20.

Revision history for this message
Seif Lotfy (seif) wrote :

u can set the interpretation by doing

from zeitgeist.mimetypes import get_interpretation_for_mimetype

then execute the method giving it a mimetype and it will return interpretation accordingly

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

> You're using USER_ACTIVITY in all cases, but if I just pull, all the changed files definitely aren't changed by the user, so
> that's clearly wrong.

No, pull is using WORLD_ACTIVITY. Check line 319

> Wouldn't it be better to just have a "change_kind" argument that can be set to "commit", "push" or "pull"

Will make that change.

> I can't shake off the feeling we're trying to somehow duplicate what the VCS system does itself - keep a commit log.

We are not storing all the information. Just the basic info as jelmer said. We are not worried about 20 commits being pulled. It is just a single event that 20 commits are being pulled.

> u can set the interpretation by doing

I saw that if I leave that field blank then the engine sets it itself.

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

> The other subjects shouldn't be set if there is no working tree (in that case the files don't exist on disk).

Can you give some examples?

> I think the other subjects should only be set in the case of push and pull, and not in the case of commit as commit doesn't actually change those files.

The think the reverse. In a commit there are various files involved. A file can be added/deleted/modified which form a part of an commit (which is an event)

In case of push and pull, we get the remote URI like bzr+shh:// which is not a valid URI for Gio.File due to which mimetype cannot be fetched.

> It would make sense to add a post_merge hook too

It would be good, but right now my plan was to get these three events and try to write a small client trying to understand how the information can be used. I have already trimmed XChat dataprovider as it was logging too much and was spamming the database with useless events. Before going ahead and adding merge/revert hooks, it would nice to know how we can use those events.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Am 24/03/12 17:54, schrieb Manish Sinha (मनीष सिन्हा):
>> The other subjects shouldn't be set if there is no working tree (in that case the files don't exist on disk).
> Can you give some examples?
You can have a branch without a working tree. E.g.:

$ bzr branch --no-tree -r5 lp:bzr-stats

will create a branch without a working tree. Running "bzr pull" there
later will pull in revisions but won't actually touch any of the
subjects the plugin now adds (as they don't exist).

>
>> I think the other subjects should only be set in the case of push and pull, and not in the case of commit as commit doesn't actually change those files.
> The think the reverse. In a commit there are various files involved. A file can be added/deleted/modified which form a part of an commit (which is an event)
The file itself doesn't change in that case though, only the branch
does. In what way is it the subject?
> In case of push and pull, we get the remote URI like bzr+shh:// which is not a valid URI for Gio.File due to which mimetype cannot be fetched.
That's not a problem - the working tree of remote branches isn't updated
by push and pull, only that of local branches.

>> It would make sense to add a post_merge hook too
> It would be good, but right now my plan was to get these three events and try to write a small client trying to understand how the information can be used. I have already trimmed XChat dataprovider as it was logging too much and was spamming the database with useless events. Before going ahead and adding merge/revert hooks, it would nice to know how we can use those events.
I think the same applies to adding too much subjects though... ?

Cheers,

Jelmer

Revision history for this message
Seif Lotfy (seif) wrote :

Every event needs a subject else it does not go into the ZG DB
In case of a commit I think we either log the fact that we committed and also add the modified and created files. Else no need to actually log the commit.

Revision history for this message
Seif Lotfy (seif) wrote :

having to many subjects is not an issue because mostly in your case we will
be using the files names as the text entry. those names will be reused
again and again.

2012/3/24 Jelmer Vernooij <email address hidden>

> Am 24/03/12 17:54, schrieb Manish Sinha (मनीष सिन्हा):
> >> The other subjects shouldn't be set if there is no working tree (in
> that case the files don't exist on disk).
> > Can you give some examples?
> You can have a branch without a working tree. E.g.:
>
> $ bzr branch --no-tree -r5 lp:bzr-stats
>
> will create a branch without a working tree. Running "bzr pull" there
> later will pull in revisions but won't actually touch any of the
> subjects the plugin now adds (as they don't exist).
>
> >
> >> I think the other subjects should only be set in the case of push and
> pull, and not in the case of commit as commit doesn't actually change those
> files.
> > The think the reverse. In a commit there are various files involved. A
> file can be added/deleted/modified which form a part of an commit (which is
> an event)
> The file itself doesn't change in that case though, only the branch
> does. In what way is it the subject?
> > In case of push and pull, we get the remote URI like bzr+shh:// which is
> not a valid URI for Gio.File due to which mimetype cannot be fetched.
> That's not a problem - the working tree of remote branches isn't updated
> by push and pull, only that of local branches.
>
> >> It would make sense to add a post_merge hook too
> > It would be good, but right now my plan was to get these three events
> and try to write a small client trying to understand how the information
> can be used. I have already trimmed XChat dataprovider as it was logging
> too much and was spamming the database with useless events. Before going
> ahead and adding merge/revert hooks, it would nice to know how we can use
> those events.
> I think the same applies to adding too much subjects though... ?
>
> Cheers,
>
> Jelmer
>
>
>
> --
>
> https://code.launchpad.net/~manishsinha/zeitgeist-datasources/bzr-improvements-subjects/+merge/99168
> You are requested to review the proposed merge of
> lp:~manishsinha/zeitgeist-datasources/bzr-improvements-subjects into
> lp:zeitgeist-datasources.
>

Revision history for this message
Michal Hruby (mhr3) wrote :

> The action is triggered by the user though, it's not an external action. If
> the user downloads a file from elsewhere onto the local system, then isn't
> that still USER_ACTIVTITY, even if the user didn't write the (entire) file?
>

That's questionable, I can have a cron job that calls bzr pull in multiple directories. As for downloading something - of course you don't need to write the file yourself for it to be considered a user activity, but in case of a download the user does in fact request that specific file, unlike bzr where you're actually saying update this repository, you don't care about the individual files.

That's why I also don't really like this approach, you're increasing global relevancy of subjects you could have actually never worked with. (consider kernel-like bzr tree and the thousands of files when you do a single pull).

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Am 24/03/12 23:14, schrieb Michal Hruby:
>> The action is triggered by the user though, it's not an external action. If
>> the user downloads a file from elsewhere onto the local system, then isn't
>> that still USER_ACTIVTITY, even if the user didn't write the (entire) file?
>>
> That's questionable, I can have a cron job that calls bzr pull in multiple directories. As for downloading something - of course you don't need to write the file yourself for it to be considered a user activity, but in case of a download the user does in fact request that specific file, unlike bzr where you're actually saying update this repository, you don't care about the individual files.
What if it's e.g. unpacking a zip file?

Anyway, I think this all depends on the zeitgeist data model and what
you want to do with it.

> That's why I also don't really like this approach, you're increasing global relevancy of subjects you could have actually never worked with. (consider kernel-like bzr tree and the thousands of files when you do a single pull).
Note that it was seif who proposed that. I think just using the branch
as subject is fine, and that's why my original branch did.

Cheers,

Jelmer

Revision history for this message
Seif Lotfy (seif) wrote :

> Am 24/03/12 23:14, schrieb Michal Hruby:
> >> The action is triggered by the user though, it's not an external action. If
> >> the user downloads a file from elsewhere onto the local system, then isn't
> >> that still USER_ACTIVTITY, even if the user didn't write the (entire) file?
> >>
> > That's questionable, I can have a cron job that calls bzr pull in multiple
> directories. As for downloading something - of course you don't need to write
> the file yourself for it to be considered a user activity, but in case of a
> download the user does in fact request that specific file, unlike bzr where
> you're actually saying update this repository, you don't care about the
> individual files.
> What if it's e.g. unpacking a zip file?
>
> Anyway, I think this all depends on the zeitgeist data model and what
> you want to do with it.
>
> > That's why I also don't really like this approach, you're increasing global
> relevancy of subjects you could have actually never worked with. (consider
> kernel-like bzr tree and the thousands of files when you do a single pull).
> Note that it was seif who proposed that. I think just using the branch
> as subject is fine, and that's why my original branch did.
>
> Cheers,
>
> Jelmer

OK you got me there. You are right. pulling stuff should not put up the subjects. The only subject should be have the uri to the directory and that is it.

Revision history for this message
Seif Lotfy (seif) wrote :

OK to sum it up.
When committing/pushing we add a subject for each changed file. When pulling or branching we just add one subject with the uri of the directory.
Tadaaaaaaaa

Revision history for this message
Siegfried Gevatter (rainct) wrote :

2012/3/25 Seif Lotfy <email address hidden>:
>> > That's why I also don't really like this approach, you're increasing global
>> relevancy of subjects you could have actually never worked with.

Not if you're only looking at UserActivity events. Events modified by
others are also relevant (ie. I may want a launcher to give me the
last files modified in a project; this is also relevant for eg.
Dropbox).

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> > I think the other subjects should only be set in the case of push and pull,
> and not in the case of commit as commit doesn't actually change those files.
>
> The think the reverse. In a commit there are various files involved. A file
> can be added/deleted/modified which form a part of an commit (which is an
> event)
The file itself isn't modified as part of commit - only the bzr branch/repo is. Modifying the files themselves was done earlier by the user using their editor.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> That's why I also don't really like this approach, you're increasing global
> relevancy of subjects you could have actually never worked with. (consider
> kernel-like bzr tree and the thousands of files when you do a single pull).
Note that this scaling issue also applies to commits, as you can commit a merge (which would involve the same amount of changes as a pull or push).

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

I talked with mhr3 and RainCT. We three agreed that we should keep files subjects out for now.

file subjects make sense only in pull request, but let's add them later instead of now

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Manish, are you updating the branch or should I ?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzr/Makefile.am'
2--- bzr/Makefile.am 2010-11-09 19:33:59 +0000
3+++ bzr/Makefile.am 2012-03-24 13:04:20 +0000
4@@ -1,7 +1,7 @@
5 EXTRA_DIST = bzr-icon-64.png
6
7 bzrplugindir = $(datadir)/pyshared/bzrlib/plugins/zeitgeist
8-dist_bzrplugin_DATA = __init__.py
9+dist_bzrplugin_DATA = __init__.py hooks.py
10
11 bzricondir = $(datadir)/pixmaps
12 bzricon_DATA = bzr-icon-64.png
13@@ -13,6 +13,7 @@
14 local-install:
15 mkdir -p $(BZR_PLUGIN_HOME_DIR)
16 cp __init__.py $(BZR_PLUGIN_HOME_DIR)
17+ cp hooks.py $(BZR_PLUGIN_HOME_DIR)
18 mkdir -p $(BZR_ICON_DIR)
19 cp bzr-icon-64.png $(BZR_ICON_DIR)
20
21
22=== modified file 'bzr/__init__.py'
23--- bzr/__init__.py 2011-08-31 13:13:33 +0000
24+++ bzr/__init__.py 2012-03-24 13:04:20 +0000
25@@ -30,102 +30,16 @@
26 Copy this directory to ~/.bazaar/plugins/zeitgeist/*
27 """
28
29-import time
30-from bzrlib import (
31- branch,
32- trace,
33- )
34-
35-_client = None
36-_client_checked = None
37-
38-def get_client():
39- global _client_checked, _client
40- if _client_checked:
41- return _client
42- _client_checked = True
43- try:
44- from zeitgeist.client import ZeitgeistClient
45- except ImportError:
46- _client = None
47- return _client
48- import dbus
49- try:
50- _client = ZeitgeistClient()
51- except dbus.DBusException, e:
52- trace.warning("zeitgeist: %s. No events will be sent." % e.message)
53- _client = None
54- except Exception, e:
55- trace.warning("Unable to connect to Zeitgeist, won't send events. "
56- "Reason: '%s'" % e)
57- _client = None
58- return _client
59-
60-
61-def post_commit(local, master, old_revno, old_revid, new_revno, new_revid):
62- client = get_client()
63- if client is None:
64- return
65- from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation
66- revision = master.repository.get_revision(new_revid)
67- if new_revno == 1:
68- interpretation = Interpretation.CREATE_EVENT
69- else:
70- interpretation = Interpretation.MODIFY_EVENT
71- _text = _("Commited on: ")
72- _text += master.base[7:-1] #don't considere file://
73- _text += _(" Revision no. : ")
74- _text += str(new_revno) + "\n"
75- _text += revision.message.rstrip()
76-
77- subject = Subject.new_for_values(
78- uri=unicode(master.base),
79- interpretation=unicode(Interpretation.FOLDER),
80- manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
81- text=unicode(_text),
82- origin=unicode(master.base),
83- )
84- event = Event.new_for_values(
85- timestamp=int(time.time()*1000),
86- interpretation=unicode(interpretation),
87- manifestation=unicode(Manifestation.USER_ACTIVITY),
88- actor="application://bzr.desktop", #something usefull here, always olive-gtk?
89- subjects=[subject,]
90- )
91- client.insert_event(event)
92-
93-
94-def post_pull(pull_result):
95- client = get_client()
96- if client is None:
97- return
98- from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation
99- master = pull_result.master_branch
100- revision = master.repository.get_revision(pull_result.new_revid)
101- interpretation = Interpretation.RECEIVE_EVENT
102- _text = _("Pulled ")
103- _text += master.base[7:-1] #don't considere file://
104- _text += (" to revision ")
105- _text += str(master.revno())+":\n"
106- _text += revision.get_summary()
107- subject = Subject.new_for_values(
108- uri=unicode(master.base),
109- interpretation=unicode(Interpretation.FOLDER),
110- manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
111- text=unicode(_text),
112- origin=unicode(master.base),
113- )
114- event = Event.new_for_values(
115- timestamp=int(time.time()*1000),
116- interpretation=unicode(interpretation),
117- manifestation=unicode(Manifestation.USER_ACTIVITY),
118- actor="application://bzr.desktop", #something usefull here, always olive-gtk?
119- subjects=[subject,]
120- )
121- client.insert_event(event)
122-
123-
124-branch.Branch.hooks.install_named_hook("post_commit", post_commit,
125- "Zeitgeist dataprovider for bzr")
126-branch.Branch.hooks.install_named_hook("post_pull", post_pull,
127- "Zeitgeist dataprovider for bzr")
128+from __future__ import absolute_import
129+
130+from bzrlib import branch
131+
132+branch.Branch.hooks.install_named_hook_lazy("post_commit",
133+ "bzrlib.plugins.zeitgeist.hooks", "post_commit",
134+ "Zeitgeist dataprovider for bzr")
135+branch.Branch.hooks.install_named_hook_lazy("post_pull",
136+ "bzrlib.plugins.zeitgeist.hooks", "post_pull",
137+ "Zeitgeist dataprovider for bzr")
138+branch.Branch.hooks.install_named_hook_lazy("post_push",
139+ "bzrlib.plugins.zeitgeist.hooks", "post_push",
140+ "Zeitgeist dataprovider for bzr")
141
142=== added file 'bzr/hooks.py'
143--- bzr/hooks.py 1970-01-01 00:00:00 +0000
144+++ bzr/hooks.py 2012-03-24 13:04:20 +0000
145@@ -0,0 +1,205 @@
146+# -.- coding: utf-8 -.-
147+
148+# Zeitgeist
149+#
150+# Copyright © 2009 Markus Korn <thekorn@gmx.de>
151+#
152+# This program is free software: you can redistribute it and/or modify
153+# it under the terms of the GNU Lesser General Public License as published by
154+# the Free Software Foundation, either version 3 of the License, or
155+# (at your option) any later version.
156+#
157+# This program is distributed in the hope that it will be useful,
158+# but WITHOUT ANY WARRANTY; without even the implied warranty of
159+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
160+# GNU Lesser General Public License for more details.
161+#
162+# You should have received a copy of the GNU Lesser General Public License
163+# along with this program. If not, see <http://www.gnu.org/licenses/>.
164+
165+import os.path
166+
167+from gi.repository import Gio
168+
169+from bzrlib import (
170+ branch,
171+ errors,
172+ trace,
173+ urlutils,
174+ workingtree,
175+ )
176+
177+_client = None
178+_client_checked = None
179+
180+def get_client():
181+ global _client_checked, _client
182+ if _client_checked:
183+ return _client
184+ _client_checked = True
185+ try:
186+ from zeitgeist.client import ZeitgeistClient
187+ except ImportError:
188+ _client = None
189+ return _client
190+ import dbus
191+ try:
192+ _client = ZeitgeistClient()
193+ except dbus.DBusException, e:
194+ trace.warning("zeitgeist: %s. No events will be sent." % e.message)
195+ _client = None
196+ except Exception, e:
197+ trace.warning("Unable to connect to Zeitgeist, won't send events. "
198+ "Reason: '%s'" % e)
199+ _client = None
200+ return _client
201+
202+
203+def subjects_for_branch(branch, new_revno, old_revno, is_push, message):
204+ """
205+ Generates the event's subject for commit, push and pull events
206+
207+ branch - the bzrlib.branch.Branch instance
208+ new_revno - the new revision number generated after a commit,
209+ after a push or a pull
210+ old_revno - the old revno which is was present before the commit,
211+ push or pull event
212+ is_push - True then push, is False then pull, is None then commit
213+ message - the Commit message
214+ """
215+
216+ from zeitgeist.datamodel import Subject, Interpretation, Manifestation
217+ location = urlutils.unescape_for_display(branch.base, "utf-8").decode("utf-8")
218+
219+ if is_push is None:
220+ # Commit
221+ text = u"Revision: %s, Message: %s" %(new_revno, message)
222+ elif is_push is True:
223+ # Push
224+ text = "Pushed branch from %s to %s" %(old_revno, new_revno)
225+ elif is_push is False:
226+ # Pull
227+ text = "Updated branch from %s to %s" %(old_revno, new_revno)
228+
229+ folder_subj = Subject.new_for_values(
230+ uri=unicode(branch.base),
231+ interpretation=unicode(Interpretation.FOLDER),
232+ manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
233+ text=text,
234+ origin=unicode(branch.base),
235+ mimetype="application/x-bzr",
236+ )
237+
238+ all_subjs = [folder_subj, ]
239+
240+ # List down the files only in case of Commit as in case of
241+ # push or pull, remote URI is used using which constructing
242+ # file URI is not possible
243+ if is_push is None:
244+ prev_tree = branch.repository.revision_tree(branch.get_rev_id(old_revno))
245+ next_tree = branch.repository.revision_tree(branch.get_rev_id(new_revno))
246+
247+ for (file_id, path, content_change, versioned, parent_id, name, kind,
248+ executable) in next_tree.iter_changes(prev_tree):
249+
250+ name = path[0] if path[0] is not None else path[1]
251+ uri = os.path.join(unicode(branch.base), name)
252+
253+ # fi.get_content_type returns the file mimetype
254+ f=Gio.File.new_for_uri(uri)
255+ fi=f.query_info("*", Gio.FileQueryInfoFlags.NONE, None)
256+
257+ subj = Subject.new_for_values(
258+ uri=uri,
259+ manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
260+ text=text,
261+ origin=unicode(branch.base),
262+ mimetype=fi.get_content_type(),
263+ )
264+ all_subjs.append(subj)
265+
266+ return all_subjs
267+
268+def get_actor():
269+ # FIXME: Allow overriding this by e.g. qbzr and bzr-gtk
270+ return u"application://bzr.desktop"
271+
272+
273+def post_commit(local, master, old_revno, old_revid, new_revno, new_revid):
274+ client = get_client()
275+ if client is None:
276+ return
277+ from zeitgeist.datamodel import Event, Interpretation, Manifestation
278+ revision = master.repository.get_revision(new_revid)
279+ if new_revno == 1:
280+ interpretation = Interpretation.CREATE_EVENT
281+ else:
282+ interpretation = Interpretation.MODIFY_EVENT
283+ _text = _("Revision: ")
284+ _text += str(new_revno) + "\n"
285+ _text += revision.message.rstrip()
286+
287+ subjects = subjects_for_branch(master, new_revno, old_revno,
288+ None, revision.message.rstrip())
289+ #subjects.set_text(_text)
290+ event = Event.new_for_values(
291+ timestamp=int(revision.timestamp*1000),
292+ interpretation=unicode(interpretation),
293+ manifestation=unicode(Manifestation.USER_ACTIVITY),
294+ actor=get_actor(),
295+ subjects=subjects,
296+ )
297+ client.insert_event(event)
298+
299+
300+def post_pull(pull_result):
301+ client = get_client()
302+ if client is None:
303+ return
304+ from zeitgeist.datamodel import Event, Interpretation, Manifestation
305+ try:
306+ revision = pull_result.master_branch.repository.get_revision(
307+ pull_result.new_revid)
308+ except errors.UnsupportedOperation:
309+ # Some remote repository formats (e.g. git) don't support looking at invidual
310+ # revisions
311+ revision = pull_result.source_branch.repository.get_revision(
312+ pull_result.new_revid)
313+ _text = _("Pulled to revision %s:\n %s") % (pull_result.new_revno,
314+ revision.get_summary())
315+ subjects = subjects_for_branch(pull_result.master_branch,
316+ pull_result.new_revno, pull_result.old_revno, False, None)
317+ event = Event.new_for_values(
318+ interpretation=unicode(Interpretation.RECEIVE_EVENT),
319+ manifestation=unicode(Manifestation.WORLD_ACTIVITY),
320+ actor=get_actor(),
321+ subjects=subjects
322+ )
323+ client.insert_event(event)
324+
325+
326+def post_push(push_result):
327+ client = get_client()
328+ if client is None:
329+ return
330+ from zeitgeist.datamodel import Event, Interpretation, Manifestation
331+ try:
332+ revision = push_result.master_branch.repository.get_revision(
333+ push_result.new_revid)
334+ except errors.UnsupportedOperation:
335+ revision = push_result.source_branch.repository.get_revision(
336+ push_result.new_revid)
337+ _text = _("Pushed to revision %s:\n %s") % (push_result.new_revno,
338+ revision.get_summary())
339+ subjects = subjects_for_branch(push_result.master_branch,
340+ push_result.new_revno, push_result.old_revno, True, None)
341+ event = Event.new_for_values(
342+ interpretation=unicode(Interpretation.SEND_EVENT),
343+ manifestation=unicode(Manifestation.USER_ACTIVITY),
344+ actor=get_actor(),
345+ subjects=subjects
346+ )
347+ client.insert_event(event)
348+
349+
350+

Subscribers

People subscribed via source and target branches