[darcs-users] Return value of hooks

Max Battcher admin at worldmaker.net
Fri May 30 02:43:58 UTC 2014

Darcs test was build specifically for this. It might be worth adding a note under pre/post-hooks in the manual that Darcs test exists as a "mid-hook" in record. As it stands the documentation to figure it out is spread through Darcs test, Darcs record, and Darcs setpref.

Darcs test predates pre-/post-hooks, which should explain why it feels so different/is documented so different.

Sent from my wireless telegraph. Full stop.
From: Ben Franksen<mailto:ben.franksen at online.de>
Sent: ‎5/‎29/‎2014 17:48
To: darcs-users at darcs.net<mailto:darcs-users at darcs.net>
Subject: Re: [darcs-users] Return value of hooks

Dmitry Bogatov wrote:
> It seems, that I can set {pre,post} -hooks for record command, but
> I cannot find a way to use their exit status.

Well, darcs commands fail immediately if the pre-hook failed. They also
"fail" (that is, return the same exit code) if the post-hook failed.

However, this is of no use to you, since the pre-hook is run before the
command even starts asking you which changes you want to record. And the
post-hook may fail, and darcs may return the same exit code, but now it is
too late: the changes to the repository are already made, and darcs does not
roll back these changes.

> What I want, is get `darcs record` to ask me to choose chunks, apply
> them, run test and refuse to record, if it fails. Is it possible?

That is, you want a post-hook that, if it fails, causes darcs to roll back
any changes it might have made.

> PS. Sorry for possible duplicate

I don't think this came up before. It would be a nice feature, but it would
also need some serious re-factoring to implement it.

As for work-arounds:

There is darcs unrecord. You can wrap your post-hook into a script that
checks for the failure, then unrecords the patch that just got recorded. If
you want to make this more fail-safe, add a pre-hook that creates a tag with
some unique name, then in case of a post-hook failure, unrecord everything
up to and including this tag.

"Make it so they have to reboot after every typo." -- Scott Adams

darcs-users mailing list
darcs-users at darcs.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20140529/61bfc108/attachment.html>

More information about the darcs-users mailing list