[PATCH] hooks: hook ordering via sort variable in [hooks]
Matt Mackall
mpm at selenic.com
Sat Jan 14 16:43:41 CST 2012
On Wed, 2012-01-11 at 10:41 -0700, Matt Zuba wrote:
> # HG changeset patch
> # User Matt Zuba <matt.zuba at goodwillaz.org>
> # Date 1326303466 25200
> # Node ID c85bcd97febe57c4e3ee928b0b7e191f14916853
> # Parent c47d69ce5208d5b5cfd2fb2f0f1d7a2b4795fbf5
> hooks: hook ordering via sort variable in [hooks]
>
> As of Mercurial 1.3, hooks are sorted in the order they are read into
> Mercurial. There are many instances when someone may want the hooks
> sorted in alphanumeric order, and this allows acheiving that by adding
> sort = True under the [hooks] config section in any hgrc file.
This needs documentation (mercurial/help/config.txt)
I don't like this much. It's all or nothing which means it's just not
going to help for lots of people.
A better approach would be a way of adding hook priorities. Something
like:
[hooks]
precommit.mine = blah
priority.precommit.mine = 1
This lets people insert their hook in arbitrary places in the list.
Note the trick with implementing this is using the existing enumeration
order as a secondary sort key.
> + hooks = ui.configitems('hooks')
> + if ('sort', 'True') in hooks:
> + hooks = sorted(hooks)
Mercurial accepts a bunch of synonyms for True vial configbool(), so
this is buggy.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list