[bzr-email:MERGED] use install_named_hook if available

Robert Collins robertc at robertcollins.net
Thu May 1 22:57:08 BST 2008


On Thu, 2008-05-01 at 15:03 -0500, John Arbash Meinel wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Just a simple compatibility thing so we don't get deprecation warnings.
> It follows the code we already had there, so I just went ahead and committed it.
> 
> John
> =:->
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (Cygwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAkgaIiYACgkQJdeBCYSNAAN5xwCfTSk1P9DC+Yu/iLIacK0qx6CA
> QOMAn3SmIw8T+2WO91exbLbMjpiIAJNv
> =v/Vn
> -----END PGP SIGNATURE-----
> plain text document attachment (email_named_hook.patch)
> # Bazaar merge directive format 2 (Bazaar 0.90)
> # revision_id: john at arbash-meinel.com-20080501200121-ovzt249cbaffyyps
> # target_branch: http://bzr.arbash-meinel.com/plugins/trunk
> # testament_sha1: e88dfccf5948207999c386bded0a0c31f11d59ef
> # timestamp: 2008-05-01 15:02:54 -0500
> # source_branch: http://bzr.arbash-meinel.com/plugins/email
> # base_revision_id: john at arbash-meinel.com-20080429140252-\
> #   782b2ugttsbpnxkp
> # 
> # Begin patch
> === modified file '__init__.py'
> --- __init__.py	2007-07-08 06:57:27 +0000
> +++ __init__.py	2008-05-01 20:01:21 +0000
> @@ -89,9 +89,13 @@
>  
>  def install_hooks():
>      """Install CommitSender to send after commits with bzr >= 0.15 """
> -    Branch.hooks.install_hook('post_commit', branch_commit_hook)
> -    if getattr(Branch.hooks, 'name_hook', None):
> -        Branch.hooks.name_hook(branch_commit_hook, "bzr-email")
> +    install_named_hook = getattr(Branch.hooks, 'install_named_hook', None)
> +    if install_named_hook:
> +        install_named_hook('post_commit', branch_commit_hook, 'bzr-email')
> +    else:
> +        Branch.hooks.install_hook('post_commit', branch_commit_hook)
> +        if getattr(Branch.hooks, 'name_hook', None):
> +            Branch.hooks.name_hook(branch_commit_hook, "bzr-email")
>  

Please use 'is not None' here, there is no telling what
install_named_hook might be :).

-Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080502/21e52910/attachment.pgp 


More information about the bazaar mailing list