[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-devel] New commands (for mtn, in lua)
From: |
William Uther |
Subject: |
[Monotone-devel] New commands (for mtn, in lua) |
Date: |
Thu, 5 Jul 2007 15:09:04 -0700 |
Hi all,
Having recently re-surfaced from a work crunch, I was looking at
what it would take to get monotone used in that work project. All
the other current project members are users of centralised version
control. To ease conversion I wanted to get some commands that were
as similar as possible to centralised commands. (Please don't tell
me I'm going about this the wrong way, unless you have a better way
to convince people who want close to a drop-in replacement for their
current system.)
Anyway, it seemed that adding new commands to monotone was a
hassle, and just introduced more design questions. People suggested
I should use scripting outside of monotone, but I wanted a cross-
platform solution. In the end, I decided to use the lua scripting
within monotone, and the net.venge.monotone.lua_cmds branch was born.
This branch adds three new lua functions:
mtn_automate(...) : This allows any of the automate commands to be
called from lua. The result is returned as a string.
alias_command( new_command, old_command) : Add a new command alias
to an existing command.
register_command(command, abstract, description, lua_function) :
Adds a new command to the "user" group of commands. When the command
is called, the associated lua function is executed. That lua will
normally use mtn_automate() calls to do its work.
I also added automate versions of the following normal commands:
push, pull, sync, merge, update and commit. These are currently not
very 'automate' friendly in that they still output everything to
standard out. They work for this purpose though.
I've also added contrib/extra-commands.lua which has the following:
-- include this in your monotonerc file to gain the extra commands.
alias_command("annotate", "blame")
alias_command("annotate", "praise")
function pmup(...)
mtn_automate("get_option", "branch") -- make sure we have a
valid workspace
mtn_automate("pull")
mtn_automate("merge")
mtn_automate("update")
end
register_command("pup", "Pull, merge and update a workspace",
"This command approximates the update command of a centralised
revision control system. " ..
"It first contacts the server to gather new revisions, then
merges multiple local heads " ..
"(if any), and then it updates the workspace.", "pmup")
function cpm(...)
mtn_automate("get_option", "branch") -- make sure we have a
valid workspace
mtn_automate("commit")
mtn_automate("pull")
heads = mtn_automate("heads")
words = 0
for word in string.gfind(heads, "[^%s]+") do words=words+1 end
if words == 1 then
mtn_automate("push")
else
mtn_automate("merge")
print("Workspace contents will not be pushed to the server.")
print("Please check that merge was successful then push
changes.")
end
end
register_command("cpm", "Commit, pull, merge and push a workspace",
"This command approximates the commit command of a centralised
revision control system.\n" ..
"It first commits your work to the local repository, then
contacts the server to gather\n" ..
"new revisions. If there is a single head at this point, then
the local changes are pushed\n" ..
"to the server. If there are multiple heads then they are
merged, and the user is asked\n" ..
"to check things still work before pushing the changes.", "cpm")
Any thoughts or suggestions?
If I was really going to do this right, I think we should replace the
entire command/options C++ codebase with a lua version, and allow it
all the be scripted/modified. But that seems like a lot of work. Is
this an acceptable half-way point?
Will :-}
- [Monotone-devel] New commands (for mtn, in lua),
William Uther <=
- [Monotone-devel] Re: New commands (for mtn, in lua), Lapo Luchini, 2007/07/06
- Re: [Monotone-devel] New commands (for mtn, in lua), Thomas Keller, 2007/07/06
- Re: [Monotone-devel] New commands (for mtn, in lua), Joel Crisp, 2007/07/06
- Re: [Monotone-devel] New commands (for mtn, in lua), Thomas Moschny, 2007/07/06