[Pkg-bazaar-commits] ./bzr-dbus/unstable r43: Fix deprecation warnings.
Jelmer Vernooij
jelmer at samba.org
Thu May 15 15:40:51 UTC 2008
------------------------------------------------------------
revno: 43
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: debian
timestamp: Thu 2008-05-15 17:40:51 +0200
message:
Fix deprecation warnings.
modified:
debian/changelog
hook.py
tests/test_hook.py
------------------------------------------------------------
revno: 33.1.3
committer: James Henstridge <james at jamesh.id.au>
branch nick: bzr-dbus.bug-198645
timestamp: Fri 2008-04-18 13:22:49 +0800
message:
Use the post_change_branch_tip hook, if it is available, instead of
set_rh.
modified:
hook.py
tests/test_hook.py
------------------------------------------------------------
revno: 33.1.4
committer: Sabin Iacob (m0n5t3r) <iacobs at m0n5t3r.info>
branch nick: bzr-dbus.install_hook
timestamp: Wed 2008-05-07 18:29:35 +0300
message:
fix deprecation warning on install_hook
modified:
hook.py
-------------- next part --------------
=== modified file 'debian/changelog'
--- a/debian/changelog 2008-05-09 22:32:22 +0000
+++ b/debian/changelog 2008-05-15 15:40:51 +0000
@@ -1,3 +1,9 @@
+bzr-dbus (0.1~bzr35-4) unstable; urgency=low
+
+ * Fix deprecation warnings when using newer versions of Bazaar.
+
+ -- Jelmer Vernooij <jelmer at samba.org> Thu, 15 May 2008 17:40:23 +0200
+
bzr-dbus (0.1~bzr35-3) unstable; urgency=low
* Add dependency on python-gobject. (Closes: #480377)
=== modified file 'hook.py'
--- a/hook.py 2007-07-08 06:41:28 +0000
+++ b/hook.py 2008-05-07 15:29:35 +0000
@@ -27,13 +27,17 @@
def install_hooks():
"""Install the dbus hooks into bzrlib."""
- Branch.hooks.install_hook('set_rh', on_set_rh)
+ if 'post_change_branch_tip' in Branch.hooks:
+ Branch.hooks.install_named_hook('post_change_branch_tip',
+ on_post_change_branch_tip, None)
+ else:
+ Branch.hooks.install_named_hook('set_rh', on_set_rh, None)
try:
SmartTCPServer.hooks
except AttributeError:
return
- SmartTCPServer.hooks.install_hook('server_started', on_server_start)
- SmartTCPServer.hooks.install_hook('server_stopped', on_server_stop)
+ SmartTCPServer.hooks.install_named_hook('server_started', on_server_start, None)
+ SmartTCPServer.hooks.install_named_hook('server_stopped', on_server_stop, None)
def on_set_rh(branch, rev_history):
@@ -41,6 +45,11 @@
activity.Activity().advertise_branch(branch)
+def on_post_change_branch_tip(params):
+ """Announce the new head revision of the branch to dbus."""
+ activity.Activity().advertise_branch(params.branch)
+
+
def on_server_start(local_urls, public_url):
"""Add the servers local and public urls to the session Broadcaster."""
for local_url in local_urls:
=== modified file 'tests/test_hook.py'
--- a/tests/test_hook.py 2008-03-19 14:43:57 +0000
+++ b/tests/test_hook.py 2008-04-18 05:22:49 +0000
@@ -27,12 +27,16 @@
class TestHooksAreSet(TestCaseWithDBus):
- def test_set_rh_installed(self):
+ def test_hooks_installed(self):
"""Loading the plugin should have installed its hooks."""
# check by looking in self._preserved hooks.
# the set_rh Branch hook to detect branch changes.
- self.assertTrue(hook.on_set_rh in
- self._preserved_hooks[Branch]['set_rh'])
+ if 'post_change_branch_tip' in self._preserved_hooks[Branch]:
+ self.assertTrue(hook.on_post_change_branch_tip in
+ self._preserved_hooks[Branch]['post_change_branch_tip'])
+ else:
+ self.assertTrue(hook.on_set_rh in
+ self._preserved_hooks[Branch]['set_rh'])
# the server_started and server_stopped smart server hooks
# to detect url maps for servers.
self.assertTrue(hook.on_server_start in
@@ -44,7 +48,11 @@
"""dbus.hook.install_hooks() should install hooks."""
hook.install_hooks()
# check the branch hooks.
- self.assertTrue(hook.on_set_rh in Branch.hooks['set_rh'])
+ if 'post_change_branch_tip' in Branch.hooks:
+ self.assertTrue(hook.on_post_change_branch_tip in
+ Branch.hooks['post_change_branch_tip'])
+ else:
+ self.assertTrue(hook.on_set_rh in Branch.hooks['set_rh'])
# check the SmartServer hooks.
self.assertTrue(hook.on_server_start in SmartTCPServer.hooks['server_started'])
self.assertTrue(hook.on_server_stop in SmartTCPServer.hooks['server_stopped'])
@@ -70,6 +78,28 @@
activity.Activity = original_class
self.assertEqual([('advertise_branch', 'branch')], calls)
+ def test_on_post_change_branch_tip_hook(self):
+ """The on_post_change_branch_tip hook should advertise the branch."""
+ calls = []
+ class SampleActivity(object):
+
+ def advertise_branch(self, branch):
+ calls.append(('advertise_branch', branch))
+
+ class FakeParams(object):
+ branch = 'branch'
+
+ # prevent api skew: check we can use the API SampleActivity presents.
+ activity.Activity(bus=self.bus).advertise_branch(self.make_branch('.'))
+ # now test the hook
+ original_class = activity.Activity
+ try:
+ activity.Activity = SampleActivity
+ hook.on_post_change_branch_tip(FakeParams)
+ finally:
+ activity.Activity = original_class
+ self.assertEqual([('advertise_branch', 'branch')], calls)
+
def test_on_server_start_hook(self):
"""The on_server_start hook should add a URL mapping for the server."""
# change the global b.p.dbus.activity.Activity to instrument
More information about the Pkg-bazaar-commits
mailing list