[darcs-devel] [issue1766] communicate with posthooks through tmp files

Max Battcher me at worldmaker.net
Mon Mar 15 18:33:46 UTC 2010


This may be a great time to rethink the environment variable approach 
altogether. Environment variables are not meant for large information 
bursts or any sort of deep program to program communication.

My suggestion is to use stdin to communicate with hook processes, rather 
than a temp file or environment variables. This is easier to test and 
generally more "unixy". Additionally, using good multi-process laziness, 
darcs should be able to avoid doing any work that the hook process 
doesn't bother reading, rather than a lot of work to prepare environment 
variables or a temp file that may not actually be used.

I'd like to see the equivalent of ``darcs changes --xml -s > 
hook-script``. (Note the ``-s``: many of my own posthooks tend to use 
the summary information, and using a stdin-based approach (or even a 
temp file approach) I think it would be useful to default to that.) I 
don't think DARCS_PATCHES, the non-xml form, is useful enough to 
preserve, but *if* it is, I would XML escape it and wrap in an XML tag 
and embed it in the XML input to the post-hook. Likewise any additional 
information that might be useful to communicate to hooks can be embedded 
in XML. It's XML, it's meant for that.

The existing environment variables should be deprecated over the course 
of a couple of releases to let scripts adapt to a stdin-based approach. 
Most hooks that already use DARCS_PATCHES_XML should have a reasonably 
easy time switching to reading stdin.

--
--Max Battcher--
http://worldmaker.net


More information about the darcs-devel mailing list