[MERGE] Show commit hook names during commit.

Robert Collins robertc at robertcollins.net
Thu Jun 28 05:09:45 BST 2007


On Thu, 2007-06-28 at 14:03 +1000, Martin Pool wrote:
> +0
> 
> (bb gets an internal error when i vote.)
> 
> @@ -494,6 +493,9 @@
>          else:
>              old_revid = bzrlib.revision.NULL_REVISION
>          for hook in Branch.hooks['post_commit']:
> +            self.pb_stage_name = "Running post commit hooks [%s]" % \
> +                Branch.hooks.get_hook_name(hook)
> +            self._emit_progress()
>              hook(hook_local, hook_master, old_revno, old_revid, new_revno,
>                  self.rev_id)
> 
> Would it maybe be better to show these as regular messages (notes)
> rather than through the progress bar, so that a view of what was done
> remains visible on the user's screen?

I don't think so. Theres a difference between 'I called the email hook'
and 'an email was sent'. So having it flip through them quickly is all
thats appropriate here IMNSHO.

> 
> +    def get_hook_name(self, a_callable):
> +        """Get the name for a_callable for UI display.
> +
> +        If no name has been registered, the string 'No hook name' is returned.
> +        """
> +        return self._callable_names.get(a_callable, "No hook name")
> 
> Would it be better to show the callable repr or class name if no name is set?

I don't think so - they are typically quite ugly or not human meaning
full. I am not -1 on the concept, but I tried it and rather hated it. I
guess for debugging it would be better, but perhaps -Dhooks could always
show the repr instead ? (I'd need a pointer at doing -D foodoo to do
this trivially).

> How about making the name an attribute of the hook object, rather than
> separately registered?  I suppose the problem is that the hooks are
> typically just callables not objects and so it is ugly to set
> attributes on them?

Thats exactly it. They are callables and its a little ugly to do
def foo(....):
    """"""
foo.name_for_bzr = "blah".
bzrlib.branch.Branch.hooks.install_hook('post_commit', foo)

Its the same amount of spelling though to do what I've done :).

-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/20070628/224faf3d/attachment.pgp 


More information about the bazaar mailing list