Merge lp:~jelmer/bzr-dbus/lazy-hooks into lp:bzr-dbus

Proposed by Jelmer Vernooij
Status: Merged
Approved by: John A Meinel
Approved revision: 48
Merged at revision: 48
Proposed branch: lp:~jelmer/bzr-dbus/lazy-hooks
Merge into: lp:bzr-dbus
Diff against target: 89 lines (+41/-22)
2 files modified
__init__.py (+41/-3)
hook.py (+0/-19)
To merge this branch: bzr merge lp:~jelmer/bzr-dbus/lazy-hooks
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+55537@code.launchpad.net

Commit message

Lazily register hooks if possible.

Description of the change

Lazily register hooks if supported by the version of bzrlib used.

This avoids loading of the smart server unless it's actually used.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/31/2011 5:03 PM, Jelmer Vernooij wrote:
> Jelmer Vernooij has proposed merging lp:~jelmer/bzr-dbus/lazy-hooks into lp:bzr-dbus.
>
> Requested reviews:
> Bazaar Developers (bzr)
>
> For more details, see:
> https://code.launchpad.net/~jelmer/bzr-dbus/lazy-hooks/+merge/55537
>
> Lazily register hooks if supported by the version of bzrlib used.
>
> This avoids loading of the smart server unless it's actually used.

 merge: approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2UmPsACgkQJdeBCYSNAAOTFwCgs22JedZ6mZOPR1T5anDpf18r
1E8AoL+E71X2zB+Ws50ZmBIton8PfDyW
=8x7X
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '__init__.py'
--- __init__.py 2010-02-11 17:55:04 +0000
+++ __init__.py 2011-03-30 13:25:38 +0000
@@ -66,14 +66,52 @@
6666
67from bzrlib import commands67from bzrlib import commands
6868
69from bzrlib.plugins.dbus.hook import install_hooks
70
71
72def test_suite():69def test_suite():
73 import tests70 import tests
74 return tests.test_suite()71 return tests.test_suite()
7572
7673
74def install_hooks():
75 """Install the dbus hooks into bzrlib."""
76 try:
77 from bzrlib.hooks import install_lazy_named_hook
78 except ImportError: # bzr < 2.4
79 from bzrlib.branch import Branch
80 from bzrlib.smart.server import SmartTCPServer
81 from bzrlib.plugins.dbus.hook import (
82 on_post_change_branch_tip,
83 on_post_commit,
84 on_server_start,
85 on_server_stop,
86 )
87 Branch.hooks.install_named_hook(
88 'post_change_branch_tip', on_post_change_branch_tip,
89 'Announcing on branch change on D-Bus')
90 Branch.hooks.install_named_hook(
91 'post_commit', on_post_commit,
92 'Zeitgeist dataprovider')
93 SmartTCPServer.hooks.install_named_hook(
94 'server_started', on_server_start,
95 'Registering server URL mapping')
96 SmartTCPServer.hooks.install_named_hook(
97 'server_stopped', on_server_stop,
98 'Unregistering server mapping')
99 else:
100 install_lazy_named_hook("bzrlib.branch", "Branch.hooks",
101 'post_change_branch_tip', "bzrlib.plugins.dbus.hook",
102 "on_post_change_branch_tip",
103 'Announcing on branch change on D-Bus')
104 install_lazy_named_hook("bzrlib.branch", "Branch.hooks",
105 'post_commit', "bzrlib.plugins.dbus.hook",
106 "on_post_commit", 'Zeitgeist dataprovider')
107 install_lazy_named_hook("bzrlib.smart.server", "SmartTCPServer.hooks",
108 'server_started', "bzrlib.plugins.dbus.hook",
109 "on_server_start", 'Registering server URL mapping')
110 install_lazy_named_hook("bzrlib.smart.server", "SmartTCPServer.hooks",
111 'server_stopped', "bzrlib.plugins.dbus.hook",
112 "on_server_stop", 'Unregistering server mapping')
113
114
77install_hooks()115install_hooks()
78116
79117
80118
=== modified file 'hook.py'
--- hook.py 2010-06-29 23:38:25 +0000
+++ hook.py 2011-03-30 13:25:38 +0000
@@ -20,25 +20,6 @@
20"""System wide hooks to trigger dbus events from bzr activity."""20"""System wide hooks to trigger dbus events from bzr activity."""
2121
2222
23from bzrlib.branch import Branch
24from bzrlib.smart.server import SmartTCPServer
25
26def install_hooks():
27 """Install the dbus hooks into bzrlib."""
28 Branch.hooks.install_named_hook(
29 'post_change_branch_tip', on_post_change_branch_tip,
30 'Announcing on branch change on D-Bus')
31 Branch.hooks.install_named_hook(
32 'post_commit', on_post_commit,
33 'Zeitgeist dataprovider')
34 SmartTCPServer.hooks.install_named_hook(
35 'server_started', on_server_start,
36 'Registering server URL mapping')
37 SmartTCPServer.hooks.install_named_hook(
38 'server_stopped', on_server_stop,
39 'Unregistering server mapping')
40
41
42def get_activity():23def get_activity():
43 import activity24 import activity
44 import dbus25 import dbus

Subscribers

People subscribed via source and target branches