[MERGE] Config.get_user_section() API

Ian Clatworthy ian.clatworthy at internode.on.net
Tue Feb 5 01:25:47 GMT 2008


Robert Collins wrote:

> What is it in aid of - you say its for enhanced hooks, but any hook can
> already ask for the appropriate config (branch/tree/location/user) and
> work with that.

It's for the hooks infrastructure to load the set of user-configured (as
opposed to plugin configured) hooks. So the idea is that a user can have
settings like this:

[pre-export-hooks]
docs = make docs

[post-commit-message-hooks]
validate = checkCommitMsg.sh

Those settings may be found in any of the config files and ought to be
combined sensibly using the normal precedence rules.

FWIW, Jelmer gets around this in his shell-hook plugin by only
supporting a single script per hook and only looking in branch.conf, e.g.

[hooks]
pre-export = make docs
post-commit-message = checkCommitMsg.sh

That is better than what we currently have ('write a plugin') but it
doesn't scale. As explained in http://bazaar-vcs.org/BzrHooks, Hg gets
around this by using an optional tagging syntax:

[hooks]
pre-export = make docs
pre-export.foo = make foo

I don't like that - I much prefer the way I'm proposing. Either way, a
get_user_section() API is needed to find the complete set of hooks.

The API is also extremely useful within a given hook or plugin. If I'm
writing an ACL hook say, there's every chance I'll want to do something
like this to get the configuration settings:

  settings = cfg.get_user_section('acl-settings')

It's true that plugins can create and use their own config files but
there are times when reusing the standard config infrastructure by
adding new sections works better.

Ian C.



More information about the bazaar mailing list