[darcs-users] in search of repository hooks

David Roundy droundy at abridgegame.org
Sun Sep 26 10:49:27 UTC 2004


On Tue, Sep 14, 2004 at 11:04:29AM +0200, Henning Thielemann wrote:
> 
> On Mon, 13 Sep 2004, Sean Perry wrote:
> 
> > We use bk here at work and I have used cvs for some time before that. A
> > common need is for some kind of 'on this action perform this external
> > action' behavior. One place I currently want this is to implement UNIX
> > file permissions so +x scripts and 644 files remain that way. It seems
> > to me that 'darcs add' could have a hook which would stat the file and
> > store the info, then whatever darcs retrieval command would read the
> > lists of perms and apply them.
> 
>  I have some other application: Maple files consist of text formatted as
> blocks rather than line oriented. By some script one can reformat Maple
> files such that the reformatted files are still readable by Maple but are
> also suitable for hunk changes and merging.  One could even write
> converters which convert binary files to text files on 'darcs record' and
> restore them after 'darcs revert' and friends.

One could do this sort of a transformation, and it's a very neat idea, but
you'd be likely to run into trouble when there are conflicts or merges,
especially if wrapping binary files, since there is no guarantee that the
merged file can be converted back into the binary format.  Probably with
Maple files, it would be fine, but in most other cases, I suspect you'd run
into trouble.

Creating a pair of commands that are run before and after every darcs
command, however, would be pretty easy, and could be used for this sort of
purpose.  I'd just use the setpref mechanism, as is used for test.  I'm
imagining a couple of prefs options, named something like "prehook" and
"posthook" which get called before and after any darcs command is run.  One
question I'm not sure the answer to is whether the posthook should be
called when darcs has failed for some reason... I imagine it should, but
perhaps multiple posthooks should be allowed, one for success and one that
would always be run.  :(
-- 
David Roundy
http://www.abridgegame.org




More information about the darcs-users mailing list