darcs

Issue 1766 communicate with posthooks via stdin or tmp files

Title communicate with posthooks via stdin or tmp files
Priority wishlist Status given-up
Milestone Resolved in
Superseder Nosy List WorldMaker, darcs-devel, dmitry.kurochkin, jaredj, kowey
Assigned To
Topics ProbablyEasy

Created on 2010-03-14.20:18:03 by kowey, last changed 2017-07-30.23:47:53 by gh.

Messages
msg10188 (view) Author: kowey Date: 2010-03-14.20:17:59
This may need some discussion on darcs-users as it affects 3rd party tools.

I just wasted a good couple of hours puzzling over our darcs/roundup
integration, until I figured out this interaction between darcs and
environment variables: 
 - due to issue672, we have to restrict environment variables to under 1k.
 - this means that if I push a lot of patches (say 50 of them), the
DARCS_PATCHES_XML string that gets created is too big... and so, we get
no environment variable

Ouch! This sort of thing makes Darcs appear to behave
non-deterministically (although it's actually perfectly deterministic,
just that the underlying cause of its behaviour is not apparent).

Perhaps a better way is to write what we have to say to a temp file, and
then use environment variables to communicate that temp file to posthooks?

Hooray for dog-food?
msg10223 (view) Author: kowey Date: 2010-03-15.11:36:46
I think this is easy enough to hack up that you should just code it up
and then start the discussion with a patch.
msg10224 (view) Author: WorldMaker Date: 2010-03-15.18:34:07
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
msg10227 (view) Author: WorldMaker Date: 2010-03-15.18:58:33
Max Battcher wrote:
> I'd like to see the equivalent of ``darcs changes --xml -s > 
> hook-script``.

Of course, that should be a pipe: darcs changes --xml -s | hook-script
History
Date User Action Args
2010-03-14 20:18:03koweycreate
2010-03-15 11:36:48koweysetstatus: needs-reproduction -> needs-implementation
messages: + msg10223
2010-03-15 18:34:12WorldMakersetnosy: + WorldMaker
messages: + msg10224
2010-03-15 18:58:35WorldMakersetmessages: + msg10227
2010-03-15 21:59:35koweysettitle: communicate with posthooks through tmp files -> communicate with posthooks via stdin or tmp files
2010-10-05 10:21:30koweylinkissue1964 superseder
2017-07-30 23:47:53ghsetstatus: needs-implementation -> given-up