On Fri, Oct 14, 2005 at 08:39:30AM -0700, Jason Dagit wrote:
> 
> On Oct 14, 2005, at 3:29 AM, Jonathon Mah wrote:
> 
> >>New --posthook option. Jason Dagit implemented a much requested
> >>feature, the posthook option. It runs a given shell command if the
> >>darcs command exits successfully, and is most useful when placed in the
> >>"defaults" configuration file.
> >
> >Posthook is really great, and allows lots of new possibilities (one of
> >which I'll post shortly). I think by default the posthook should _not_
> >run when a command is cancelled (e.g. cancelling during an interactive
> >record).
> 
> I don't have the code in front of me, but I think all we would have to do
> is changed the exit code to non-zero when a command in cancelled.  Should
> be easy to fix, but don't expect me to do it as I have my hands full at
> the moment.  It would be a nice simple thing for someone that wants to
> get started with contributing to darcs.

Indeed, that is correct.  The question, though, is whether we really want
to exit with failure on cancelled commands.  We'd also have to decide
whether to exit with failure when no patches are available (or match the
--patches arguments).  I'd lean against failing in either case, since it
seems we should do the same thing in both cases, and it seems weird for
pull to fail when there are no patches to pull.  On the other hand, maybe
that's precisely what we want--perhaps pull should fail if there are no
patches, and then you could write a cron job such as:

darcs pull -a && ./expensive_update_script

(Of course, one could equally well write this as a posthook.)

Hmmm.  I'm hesitant to modify the exit code behavior as this is something
that scripts may rely on.  I don't think quitting is really an error, and
it's nice for scripts to know if something "really" went wrong just by
checking for error on exit code.  Yes, we could have a particular exit code
mean "no changes" but that requires a bit more complexity in scripting...

Another possibility would be to create a variant of --post-hook that
doesn't run at all if exitWith is called--only if a command returns.  This
would run generally when a command runs to completion.  We could call it
something like --completion-hook.  Then we'd ideally have to audit the code
to make sure we don't ever use exitWith when we've actually done some work,
but I think this is usually the case.

Another factor is that we will eventually want to add env var support to
pass data to hooks, and an obvious datum to pass would be
"NUMCHANGES"--which is defined for most darcs commands.
-- 
David Roundy
http://www.darcs.net

_______________________________________________
darcs-users mailing list
[email protected]
http://www.abridgegame.org/mailman/listinfo/darcs-users

Reply via email to