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
=== modified file 'bzr/Makefile.am'
--- bzr/Makefile.am 2010-11-09 19:33:59 +0000
+++ bzr/Makefile.am 2012-03-24 13:04:20 +0000
@@ -1,7 +1,7 @@
1EXTRA_DIST = bzr-icon-64.png1EXTRA_DIST = bzr-icon-64.png
22
3bzrplugindir = $(datadir)/pyshared/bzrlib/plugins/zeitgeist3bzrplugindir = $(datadir)/pyshared/bzrlib/plugins/zeitgeist
4dist_bzrplugin_DATA = __init__.py4dist_bzrplugin_DATA = __init__.py hooks.py
55
6bzricondir = $(datadir)/pixmaps6bzricondir = $(datadir)/pixmaps
7bzricon_DATA = bzr-icon-64.png7bzricon_DATA = bzr-icon-64.png
@@ -13,6 +13,7 @@
13local-install:13local-install:
14 mkdir -p $(BZR_PLUGIN_HOME_DIR)14 mkdir -p $(BZR_PLUGIN_HOME_DIR)
15 cp __init__.py $(BZR_PLUGIN_HOME_DIR)15 cp __init__.py $(BZR_PLUGIN_HOME_DIR)
16 cp hooks.py $(BZR_PLUGIN_HOME_DIR)
16 mkdir -p $(BZR_ICON_DIR)17 mkdir -p $(BZR_ICON_DIR)
17 cp bzr-icon-64.png $(BZR_ICON_DIR)18 cp bzr-icon-64.png $(BZR_ICON_DIR)
1819
1920
=== modified file 'bzr/__init__.py'
--- bzr/__init__.py 2011-08-31 13:13:33 +0000
+++ bzr/__init__.py 2012-03-24 13:04:20 +0000
@@ -30,102 +30,16 @@
30Copy this directory to ~/.bazaar/plugins/zeitgeist/*30Copy this directory to ~/.bazaar/plugins/zeitgeist/*
31"""31"""
3232
33import time33from __future__ import absolute_import
34from bzrlib import (34
35 branch,35from bzrlib import branch
36 trace,36
37 )37branch.Branch.hooks.install_named_hook_lazy("post_commit",
3838 "bzrlib.plugins.zeitgeist.hooks", "post_commit",
39_client = None39 "Zeitgeist dataprovider for bzr")
40_client_checked = None40branch.Branch.hooks.install_named_hook_lazy("post_pull",
4141 "bzrlib.plugins.zeitgeist.hooks", "post_pull",
42def get_client():42 "Zeitgeist dataprovider for bzr")
43 global _client_checked, _client43branch.Branch.hooks.install_named_hook_lazy("post_push",
44 if _client_checked:44 "bzrlib.plugins.zeitgeist.hooks", "post_push",
45 return _client45 "Zeitgeist dataprovider for bzr")
46 _client_checked = True
47 try:
48 from zeitgeist.client import ZeitgeistClient
49 except ImportError:
50 _client = None
51 return _client
52 import dbus
53 try:
54 _client = ZeitgeistClient()
55 except dbus.DBusException, e:
56 trace.warning("zeitgeist: %s. No events will be sent." % e.message)
57 _client = None
58 except Exception, e:
59 trace.warning("Unable to connect to Zeitgeist, won't send events. "
60 "Reason: '%s'" % e)
61 _client = None
62 return _client
63
64
65def post_commit(local, master, old_revno, old_revid, new_revno, new_revid):
66 client = get_client()
67 if client is None:
68 return
69 from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation
70 revision = master.repository.get_revision(new_revid)
71 if new_revno == 1:
72 interpretation = Interpretation.CREATE_EVENT
73 else:
74 interpretation = Interpretation.MODIFY_EVENT
75 _text = _("Commited on: ")
76 _text += master.base[7:-1] #don't considere file://
77 _text += _(" Revision no. : ")
78 _text += str(new_revno) + "\n"
79 _text += revision.message.rstrip()
80
81 subject = Subject.new_for_values(
82 uri=unicode(master.base),
83 interpretation=unicode(Interpretation.FOLDER),
84 manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
85 text=unicode(_text),
86 origin=unicode(master.base),
87 )
88 event = Event.new_for_values(
89 timestamp=int(time.time()*1000),
90 interpretation=unicode(interpretation),
91 manifestation=unicode(Manifestation.USER_ACTIVITY),
92 actor="application://bzr.desktop", #something usefull here, always olive-gtk?
93 subjects=[subject,]
94 )
95 client.insert_event(event)
96
97
98def post_pull(pull_result):
99 client = get_client()
100 if client is None:
101 return
102 from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation
103 master = pull_result.master_branch
104 revision = master.repository.get_revision(pull_result.new_revid)
105 interpretation = Interpretation.RECEIVE_EVENT
106 _text = _("Pulled ")
107 _text += master.base[7:-1] #don't considere file://
108 _text += (" to revision ")
109 _text += str(master.revno())+":\n"
110 _text += revision.get_summary()
111 subject = Subject.new_for_values(
112 uri=unicode(master.base),
113 interpretation=unicode(Interpretation.FOLDER),
114 manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
115 text=unicode(_text),
116 origin=unicode(master.base),
117 )
118 event = Event.new_for_values(
119 timestamp=int(time.time()*1000),
120 interpretation=unicode(interpretation),
121 manifestation=unicode(Manifestation.USER_ACTIVITY),
122 actor="application://bzr.desktop", #something usefull here, always olive-gtk?
123 subjects=[subject,]
124 )
125 client.insert_event(event)
126
127
128branch.Branch.hooks.install_named_hook("post_commit", post_commit,
129 "Zeitgeist dataprovider for bzr")
130branch.Branch.hooks.install_named_hook("post_pull", post_pull,
131 "Zeitgeist dataprovider for bzr")
13246
=== added file 'bzr/hooks.py'
--- bzr/hooks.py 1970-01-01 00:00:00 +0000
+++ bzr/hooks.py 2012-03-24 13:04:20 +0000
@@ -0,0 +1,205 @@
1# -.- coding: utf-8 -.-
2
3# Zeitgeist
4#
5# Copyright © 2009 Markus Korn <thekorn@gmx.de>
6#
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.
11#
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.
16#
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/>.
19
20import os.path
21
22from gi.repository import Gio
23
24from bzrlib import (
25 branch,
26 errors,
27 trace,
28 urlutils,
29 workingtree,
30 )
31
32_client = None
33_client_checked = None
34
35def get_client():
36 global _client_checked, _client
37 if _client_checked:
38 return _client
39 _client_checked = True
40 try:
41 from zeitgeist.client import ZeitgeistClient
42 except ImportError:
43 _client = None
44 return _client
45 import dbus
46 try:
47 _client = ZeitgeistClient()
48 except dbus.DBusException, e:
49 trace.warning("zeitgeist: %s. No events will be sent." % e.message)
50 _client = None
51 except Exception, e:
52 trace.warning("Unable to connect to Zeitgeist, won't send events. "
53 "Reason: '%s'" % e)
54 _client = None
55 return _client
56
57
58def subjects_for_branch(branch, new_revno, old_revno, is_push, message):
59 """
60 Generates the event's subject for commit, push and pull events
61
62 branch - the bzrlib.branch.Branch instance
63 new_revno - the new revision number generated after a commit,
64 after a push or a pull
65 old_revno - the old revno which is was present before the commit,
66 push or pull event
67 is_push - True then push, is False then pull, is None then commit
68 message - the Commit message
69 """
70
71 from zeitgeist.datamodel import Subject, Interpretation, Manifestation
72 location = urlutils.unescape_for_display(branch.base, "utf-8").decode("utf-8")
73
74 if is_push is None:
75 # Commit
76 text = u"Revision: %s, Message: %s" %(new_revno, message)
77 elif is_push is True:
78 # Push
79 text = "Pushed branch from %s to %s" %(old_revno, new_revno)
80 elif is_push is False:
81 # Pull
82 text = "Updated branch from %s to %s" %(old_revno, new_revno)
83
84 folder_subj = Subject.new_for_values(
85 uri=unicode(branch.base),
86 interpretation=unicode(Interpretation.FOLDER),
87 manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
88 text=text,
89 origin=unicode(branch.base),
90 mimetype="application/x-bzr",
91 )
92
93 all_subjs = [folder_subj, ]
94
95 # List down the files only in case of Commit as in case of
96 # push or pull, remote URI is used using which constructing
97 # file URI is not possible
98 if is_push is None:
99 prev_tree = branch.repository.revision_tree(branch.get_rev_id(old_revno))
100 next_tree = branch.repository.revision_tree(branch.get_rev_id(new_revno))
101
102 for (file_id, path, content_change, versioned, parent_id, name, kind,
103 executable) in next_tree.iter_changes(prev_tree):
104
105 name = path[0] if path[0] is not None else path[1]
106 uri = os.path.join(unicode(branch.base), name)
107
108 # fi.get_content_type returns the file mimetype
109 f=Gio.File.new_for_uri(uri)
110 fi=f.query_info("*", Gio.FileQueryInfoFlags.NONE, None)
111
112 subj = Subject.new_for_values(
113 uri=uri,
114 manifestation=unicode(Manifestation.FILE_DATA_OBJECT),
115 text=text,
116 origin=unicode(branch.base),
117 mimetype=fi.get_content_type(),
118 )
119 all_subjs.append(subj)
120
121 return all_subjs
122
123def get_actor():
124 # FIXME: Allow overriding this by e.g. qbzr and bzr-gtk
125 return u"application://bzr.desktop"
126
127
128def post_commit(local, master, old_revno, old_revid, new_revno, new_revid):
129 client = get_client()
130 if client is None:
131 return
132 from zeitgeist.datamodel import Event, Interpretation, Manifestation
133 revision = master.repository.get_revision(new_revid)
134 if new_revno == 1:
135 interpretation = Interpretation.CREATE_EVENT
136 else:
137 interpretation = Interpretation.MODIFY_EVENT
138 _text = _("Revision: ")
139 _text += str(new_revno) + "\n"
140 _text += revision.message.rstrip()
141
142 subjects = subjects_for_branch(master, new_revno, old_revno,
143 None, revision.message.rstrip())
144 #subjects.set_text(_text)
145 event = Event.new_for_values(
146 timestamp=int(revision.timestamp*1000),
147 interpretation=unicode(interpretation),
148 manifestation=unicode(Manifestation.USER_ACTIVITY),
149 actor=get_actor(),
150 subjects=subjects,
151 )
152 client.insert_event(event)
153
154
155def post_pull(pull_result):
156 client = get_client()
157 if client is None:
158 return
159 from zeitgeist.datamodel import Event, Interpretation, Manifestation
160 try:
161 revision = pull_result.master_branch.repository.get_revision(
162 pull_result.new_revid)
163 except errors.UnsupportedOperation:
164 # Some remote repository formats (e.g. git) don't support looking at invidual
165 # revisions
166 revision = pull_result.source_branch.repository.get_revision(
167 pull_result.new_revid)
168 _text = _("Pulled to revision %s:\n %s") % (pull_result.new_revno,
169 revision.get_summary())
170 subjects = subjects_for_branch(pull_result.master_branch,
171 pull_result.new_revno, pull_result.old_revno, False, None)
172 event = Event.new_for_values(
173 interpretation=unicode(Interpretation.RECEIVE_EVENT),
174 manifestation=unicode(Manifestation.WORLD_ACTIVITY),
175 actor=get_actor(),
176 subjects=subjects
177 )
178 client.insert_event(event)
179
180
181def post_push(push_result):
182 client = get_client()
183 if client is None:
184 return
185 from zeitgeist.datamodel import Event, Interpretation, Manifestation
186 try:
187 revision = push_result.master_branch.repository.get_revision(
188 push_result.new_revid)
189 except errors.UnsupportedOperation:
190 revision = push_result.source_branch.repository.get_revision(
191 push_result.new_revid)
192 _text = _("Pushed to revision %s:\n %s") % (push_result.new_revno,
193 revision.get_summary())
194 subjects = subjects_for_branch(push_result.master_branch,
195 push_result.new_revno, push_result.old_revno, True, None)
196 event = Event.new_for_values(
197 interpretation=unicode(Interpretation.SEND_EVENT),
198 manifestation=unicode(Manifestation.USER_ACTIVITY),
199 actor=get_actor(),
200 subjects=subjects
201 )
202 client.insert_event(event)
203
204
205

Subscribers

People subscribed via source and target branches