[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-devel] Errors when updating a custom command for 0.43
From: |
John Bailey |
Subject: |
[Monotone-devel] Errors when updating a custom command for 0.43 |
Date: |
Sat, 23 May 2009 21:45:24 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.19) Gecko/20090103 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666 |
Hi, everyone,
One of my fellow Pidgin developers wrote a "pluck-log" command into his
.monotone/monotonerc whose purpose is to pluck a revision or a series of
revisions and grab the original changelog(s) for use in the changelog for the
resulting revision. His original code was this:
function find_topsrcdir()
local path = "."
local f
while 1 do
f = io.open(path .. "/_MTN/", "r")
if f then break end
path = path .. "/.."
end
f:close()
return path
end
-- pluck-log command
function pluck_log(...)
local revs = {...}
topsrcdir = find_topsrcdir()
local logfile = io.open(topsrcdir .. "/_MTN/log", "r")
local log = ""
if logfile then
log = logfile:read("*all")
logfile:close()
end
table.foreach(revs,
function (index, rev)
r, sel = mtn_automate("select", rev)
if r == false then return end
for rev in sel:gmatch("%S+") do
r, certs = mtn_automate("certs", rev)
certs:gsub("%s+key \"(.-)\"\n%s*signature \"(.-)\"\n%s*name
\"(.-)\"\n%s*value \"(.-)\"\n%s*trust \"(.-)\"",
function(key, sig, name, value, trust)
if name == "changelog" then
log = log .. "*** Plucked rev " ..
string.sub(rev, 0, 8) .. " (" .. key .. "):\n" .. value .. "\n"
end
end
)
execute("mtn", "pluck", "-r", rev)
end
end
)
logfile = io.open(topsrcdir .. "/_MTN/log", "w")
logfile:write(log)
logfile:close()
end
register_command("pluck-log", "REVISION1 [REVISION2 [...]]", "Pluck a revision
with a good log",
"This plucks a list of revisions, each individually, and adds the
changelog of each revision for the next commit log." ..
"\nEXAMPLE:\tmtn pluck-log h:im.pidgin.pidgin deadbeef\n",
"pluck_log")
As it is, this code worked. However, knowing that 'mtn automate
get_workspace_root' exists in mtn 0.43 and newer, I set out to update the
command to take advantage of the new automate feature. My revised code drops
the find_topsrcdir function in favor of mtn_automate. I also removed the
trimming of the revision ID, thus causing the entire revision ID to be printed
instead of just the first 8 digits. The new code looks like this:
-- pluck-log command
function pluck_log(...)
local revs = {...}
local result,topsrcdir = mtn_automate("get_workspace_root")
local logfile = io.open(topsrcdir .. "/_MTN/log", "r")
local log = ""
if logfile then
log = logfile:read("*all")
logfile:close()
end
table.foreach(revs,
function (index, rev)
r, sel = mtn_automate("select", rev)
if r == false then return end
for rev in sel:gmatch("%S+") do
r, certs = mtn_automate("certs", rev)
certs:gsub("%s+key \"(.-)\"\n%s*signature \"(.-)\"\n%s*name
\"(.-)\"\n%s*value \"(.-)\"\n%s*trust \"(.-)\"",
function(key, sig, name, value, trust)
if name == "changelog" then
log = log .. "*** Plucked rev " .. rev .. " ("
.. key .. "):\n" .. value .. "\n"
end
end
)
execute("mtn", "pluck", "-r", rev)
end
end
)
logfile = io.open(topsrcdir .. "/_MTN/log", "w")
logfile:write(log)
logfile:close()
end
register_command("pluck-log", "REVISION1 [REVISION2 [...]]", "Pluck a revision
with a good log",
"This plucks a list of revisions, each individually, and adds the
changelog of each revision for the next commit log." ..
"\nEXAMPLE:\tmtn pluck-log h:im.pidgin.pidgin deadbeef\n",
"pluck_log")
However, when I use the updated pluck-log command, I get the following error:
>>$ mtn pluck-log 074c5aedf9bbc512331f0d3130f076190b290676
mtn: [left] 61175582f54c5b32f2896ecaddeede75a1bae0f8
mtn: [right] 074c5aedf9bbc512331f0d3130f076190b290676
mtn: modifying libpurple/protocols/yahoo/yahoo.h
mtn: applied changes to workspace
mtn: warning: /home/jbailey/.monotone/monotonerc:48: attempt to index local
'logfile' (a nil value)
mtn: misuse: Call to user command pluck-log (lua command: pluck_log) failed.
In my monotonerc, line 48 is the second io.open in the new code shown.
To put to rest the obvious first question:
>>$ mtn --version
monotone 0.43 (base revision: ddc6546051abf6475c40a3fdba272e2f82a40e94)
Any insight would be greatly appreciated.
Thanks,
John
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-devel] Errors when updating a custom command for 0.43,
John Bailey <=