'start_commit' hook is unhookable?

Jelmer Vernooij jelmer at samba.org
Sat Aug 2 19:06:21 BST 2008


Hi Brian,

Am Samstag, den 02.08.2008, 11:51 -0600 schrieb Brian de Alwis:
> So I hacked together a tiny plugin to use the 'start_commit' hook to  
> clear exec bits for a tree.  This failed on bzr 1.5, but I wrote the  
> failure off at the time thinking that 'start_commit' must have been a  
> new hook for 1.6.  But I've just installed 1.6b3 and the problem is  
> there.  And poking around, I discovered that 'start_commit' was  
> actually added in 1.4.
> 
[...]
> I've attached my simple plugin here.
> 
> ------------------------------------------------------------
> # For projects defining 'clear_exec_bit = on', this hook will first
> # perform a `chmod a-x' for all files as a pre-commit hook.
> 
> import os
> from bzrlib import urlutils
> from bzrlib.branch import Branch
> from bzrlib.config import LocationConfig
> 
> def start_commit_hook(tree):
>      config = LocationConfig(tree.basedir) 	# unsure if this is right
>      # maybe this should specify glob patterns instead...
>      enabled = (config.get_user_option('clear_exec_bit') in
>          (u'on', u'yes', u'ye', u'y'))
>      if not enabled:
>          return
> 
>      base = tree.basedir # it's how cmd_root does it
>      # questionable whether single-quoting is the right thing
>      print "clearing exec bits in " + base
>      os.system("find '" + base + "' -type f -print0 | xargs -0 chmod
> a- 
> x")
> 
> Branch.hooks.install_named_hook(
>     'start_commit', start_commit_hook, 'clear executable bit')
^^^^^^^^ 

start_commit is a hook on MutableTree, not on Branch, so you'd probably
want that last line to read:

MutableTree.hooks.install_named_hook('start_commit', start_commit_hook,
'clear executable bit')

Cheers,

Jelmer
-- 
Jelmer Vernooij <jelmer at samba.org> - http://samba.org/~jelmer/
Jabber: jelmer at jabber.fsfe.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080802/d1a2dd6f/attachment.pgp 


More information about the bazaar mailing list