monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] New commands (for mtn, in lua)


From: William Uther
Subject: Re: [Monotone-devel] New commands (for mtn, in lua)
Date: Tue, 4 Sep 2007 10:20:23 +1000


On 04/09/2007, at 7:29 AM, Matthew Sackman wrote:

On Fri, Jul 06, 2007 at 10:17:22AM -0700, William Uther wrote:
On 06/07/2007, at 9:00 AM, address@hidden wrote:
On Friday 06 July 2007, William Uther wrote:
mtn_automate(...) : This allows any of the automate commands to be
called from lua.  The result is returned as a string.

Seems like something one really wants to have.

However, there is potential for deadlocks, when some command calls a Lua
hook
that calls an automate command that calls a Lua hook...

I didn't want lua hooks calling automate commands because I wasn't sure
what that would do, and I didn't
think it was necessary. So there is a flag in the code that only turns
mtn_automate on when it is being
called from a user command. It also turns the flag off inside mtn_automate
itself so you can't get
recursion (you'll get an error if you try).

Agh. I'm still running 0.36, so do tell if this has been changed, but
looking at the code, it hasn't.

This is a major pain for me. I would like to be able to write hooks
that, eg on note_netsync_revision_received, take the revision and can
get hold of parents, or do diffs. This flag would seem to prevent me
from doing that.

Now at this point I don't mind if you want to prohibit any automate
command that can modify the mtn database and just want to allow pure
functions, that would suit me fine. But err, it would be great to get
this functionality to work.

There is a lot to test there. If you want to try it, you could search the code for "mtn_automate_allowed". It is the boolean flag that switches the mtn_automate lua function on and off. The definition of the mtn_automate lua function is in cmd_automate.cc; look for LUAEXT(mtn_automate, ). There is a check there:

      E(app_p->mtn_automate_allowed,
          F("It is illegal to call the mtn_automate() lua extension,\n"
"unless from a command function defined by register_command()."));

If you comment out that check, then you can test for yourself what works and what doesn't.

As I said, the reason I put that check in was that I wasn't sure that it would work, not because I was sure that it wouldn't.

Be well,

Will        :-}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]