[darcs-devel] [PATCH] run a hook for each patch on apply

Olivier Thauvin olivier.thauvin at aerov.jussieu.fr
Wed Feb 1 23:19:20 PST 2006


Le Mardi 31 Janvier 2006 09:07, Jason Dagit a écrit :
> On Jan 30, 2006, at 10:30 PM, Olivier Thauvin wrote:
> > This patch make darcs running a script for each patch apply by 'apply'
> > command.
>
> Very nice.
>
> > If exists, _darcs/prefs/onapply is called with patch hash as first
> > argument. The goal is clearly to send a mail when a new commit is
> > done on a
> > main repository. This cannot be done properly with standard
> > posthook as he
> > don't remain which patch was applied during darcs call.
> >
> > The _darcs/prefs/onapply script should be executable.
>
> Is it possible to make this script part of the already existing
> prefs?  Or better yet, could all commands which work on patches pass
> the patch hashes on the command line?  I think this would give an
> overall consistency.

I had a look to use the current pref implementation, but this create two 
problems:

- the current functions which get pref works with 'opt', aka the result of 
arguments passed on command line, so currently, a split of the function to 
have one using opt calling the second with more independent format arguments 
([String] instead [DarcsFlags]) is need I think.

- the second is the current way of setting post-hook: aka setting the full 
command line: aka "command arg1 arg2 ...", adding to the end the patch hash 
force the user to deal in its script with the argument count. I mean if I 
set:

./foo "mail"

I'll have to understand the patch hash is $2 as I passed myself $1. The 
current patch works like CVS or Subversion, calling script, and patch name is 
allways at $1. But with proper documentation, this is probably not a problem.

About making all command using a per patch posthook: each command have to be 
patch to do this, so the function running the script has to be moved into 
DarcsExternal.lhs to factorize code. I made it because the current posthook 
is run too late to know what patches was modified. But nothing is impossible 
again, and I can try to do this easilly.

In a nutshell, a proper way would be to create a new pref called something 
like "prepatch-posthook COMMAND", working only for record, apply, pull, 
etc...

Will work on it to provide a patch over this one.

>
> On the whole I like it, perhaps others like the changes I suggest and
> they are relatively easy to implement?

So yes, after propably patching some allready existing code to 
factorize/reduce code duplication, yes I think, and will work on it if 
everybody agree this kind of thing are interesting.

I was trying to first make a non intrusive code to have darcs-devel point of 
view, if it's ok, let's go.

BTW: I am still a beginner with haskell, so all comment about my code are 
welcome to help me to learn this nice language.


A last point, I used the power of darcs behaviour to provide my own darcs 
repository, I think this make easier the work of darcs-unstable maintainers 
to get my patch for testing/upstream integration. All patch I submit on this 
list are availlable here:

http://nanardon.zarb.org/darcsweb/darcsweb.cgi?r=darcs;a=summary

So you can get my patches with:
darcs get http://nanardon.homelinux.org/darcs/darcs

>
> Thanks,
> Jason
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.osuosl.org/pipermail/darcs-devel/attachments/20060202/2f8a39e4/attachment.pgp


More information about the darcs-devel mailing list