[darcs-users] determining what darcs apply did [was: sending notices when a repo changes]

David Roundy droundy at abridgegame.org
Tue Mar 8 13:50:16 UTC 2005


I think we've got a pretty good set of ideas for what sort of interface to
use with hooks.  I'm pretty much sold on the idea of using environment
variables for most "generic" information (e.g. what darcs command was
called), and using separate flags for "event-specific" hooks.

I think the simplest hook will be the simple --post-hook, which is called
when darcs exits successfully, and I think this would be a good hook to
start with.  It's also a particularly useful hook.  It doesn't necesarily
require any interesting input to be useful--often I'd just like to run make
after darcs apply is run--so we could add input incrementally, with the
hook being useful even before there are any inputs (via environment
variables).

I imagine we'll want a module that'll handle hook-calling, which will
(eventually) deal with setting whatever environment variables we want to
pass, and calling the hook itself.  I imagine that module exporting
something like

run_hook :: (DarcsFlag -> Maybe String) -> [DarcsFlag]
         -> [(String,Doc)] -> IO ExitCode

where the [(String,Doc)] indicates the contents of desired environment
variables, and the first argument would be an accessor that would be
something like

get_posthook :: DarcsFlag -> Maybe String
get_posthook (PostHook s) = Just s
get_posthook _ = Nothing

I'm not married to this interface, but something roughly similar would seem
wise.  The theory of the get_posthook sort of interface is that there might
be two mutually exclusive flags that fall in the same "hook category", such
as --pre-hook-conditional and --pre-hook-ignore-exitcode (which would
deserve better names), which would both be run as a "pre-hook" command, but
in the latter case, run_hook would always return ExitSuccess, regardless of
the return value of the hook.

Does anyone want to volunteer to implement something like this? Of course,
he who implements the code gets to choose the design (except that of course
I'll object if it's too horrendous).
-- 
David Roundy
http://www.darcs.net




More information about the darcs-users mailing list