* use the built-in push_hook_functions to register the netsync hooks,
this way additional hooks which need these notifications as well do not override earlier hooks * optionally include an additional hooks.lua file at the very end in which custom hooks can be defined
This commit is contained in:
parent
c807c4b734
commit
8a55952204
@ -34,30 +34,37 @@ end
|
|||||||
-- let IDF know of new arriving revisions to fill its timeline
|
-- let IDF know of new arriving revisions to fill its timeline
|
||||||
--
|
--
|
||||||
_idf_revs = {}
|
_idf_revs = {}
|
||||||
function note_netsync_start(session_id)
|
push_hook_functions({
|
||||||
_idf_revs[session_id] = {}
|
["start"] = function (session_id)
|
||||||
end
|
_idf_revs[session_id] = {}
|
||||||
|
return "continue",nil
|
||||||
|
end,
|
||||||
|
["revision_received"] = function (new_id, revision, certs, session_id)
|
||||||
|
table.insert(_idf_revs[session_id], new_id)
|
||||||
|
return "continue",nil
|
||||||
|
end,
|
||||||
|
["end"] = function (session_id, ...)
|
||||||
|
if table.getn(_idf_revs[session_id]) == 0 then
|
||||||
|
return "continue",nil
|
||||||
|
end
|
||||||
|
|
||||||
function note_netsync_revision_received(new_id, revision, certs, session_id)
|
local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%");
|
||||||
table.insert(_idf_revs[session_id], new_id)
|
if pid == -1 then
|
||||||
end
|
print("could not execute %%MTNPOSTPUSH%%")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
function note_netsync_end (session_id, ...)
|
for _,r in ipairs(_idf_revs[session_id]) do
|
||||||
if table.getn(_idf_revs[session_id]) == 0 then
|
pin:write(r .. "\n")
|
||||||
return
|
end
|
||||||
|
pin:close()
|
||||||
|
|
||||||
|
wait(pid)
|
||||||
|
return "continue",nil
|
||||||
end
|
end
|
||||||
|
})
|
||||||
|
|
||||||
local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%");
|
--
|
||||||
if pid == -1 then
|
-- Load additional local hooks, in case they exist
|
||||||
print("could execute %%MTNPOSTPUSH%%")
|
--
|
||||||
return
|
include(get_confdir() .. "/hooks.lua")
|
||||||
end
|
|
||||||
|
|
||||||
for _,r in ipairs(_idf_revs[session_id]) do
|
|
||||||
pin:write(r .. "\n")
|
|
||||||
end
|
|
||||||
pin:close()
|
|
||||||
|
|
||||||
wait(pid)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ function get_remote_automate_permitted(key_identity, command, options)
|
|||||||
"leaves", "ancestry_difference", "toposort", "erase_ancestors",
|
"leaves", "ancestry_difference", "toposort", "erase_ancestors",
|
||||||
"descendents", "ancestors", "heads", "get_file_of", "get_file",
|
"descendents", "ancestors", "heads", "get_file_of", "get_file",
|
||||||
"interface_version", "get_attributes", "content_diff",
|
"interface_version", "get_attributes", "content_diff",
|
||||||
"file_merge", "show_conflicts", "certs", "keys"
|
"file_merge", "show_conflicts", "certs", "keys", "get_file_size",
|
||||||
|
"get_extended_manifest_of"
|
||||||
}
|
}
|
||||||
|
|
||||||
for _,v in ipairs(read_only_commands) do
|
for _,v in ipairs(read_only_commands) do
|
||||||
@ -47,29 +48,37 @@ end
|
|||||||
-- let IDF know of new arriving revisions to fill its timeline
|
-- let IDF know of new arriving revisions to fill its timeline
|
||||||
--
|
--
|
||||||
_idf_revs = {}
|
_idf_revs = {}
|
||||||
function note_netsync_start(session_id)
|
push_hook_functions({
|
||||||
_idf_revs[session_id] = {}
|
["start"] = function (session_id)
|
||||||
end
|
_idf_revs[session_id] = {}
|
||||||
|
return "continue",nil
|
||||||
|
end,
|
||||||
|
["revision_received"] = function (new_id, revision, certs, session_id)
|
||||||
|
table.insert(_idf_revs[session_id], new_id)
|
||||||
|
return "continue",nil
|
||||||
|
end,
|
||||||
|
["end"] = function (session_id, ...)
|
||||||
|
if table.getn(_idf_revs[session_id]) == 0 then
|
||||||
|
return "continue",nil
|
||||||
|
end
|
||||||
|
|
||||||
function note_netsync_revision_received(new_id, revision, certs, session_id)
|
local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%");
|
||||||
table.insert(_idf_revs[session_id], new_id)
|
if pid == -1 then
|
||||||
end
|
print("could not execute %%MTNPOSTPUSH%%")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
function note_netsync_end (session_id, ...)
|
for _,r in ipairs(_idf_revs[session_id]) do
|
||||||
if table.getn(_idf_revs[session_id]) == 0 then
|
pin:write(r .. "\n")
|
||||||
return
|
end
|
||||||
|
pin:close()
|
||||||
|
|
||||||
|
wait(pid)
|
||||||
|
return "continue",nil
|
||||||
end
|
end
|
||||||
|
})
|
||||||
|
|
||||||
local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%");
|
--
|
||||||
if pid == -1 then
|
-- Load additional local hooks, in case they exist
|
||||||
print("could execute %%MTNPOSTPUSH%%")
|
--
|
||||||
return
|
include(get_confdir() .. "/hooks.lua")
|
||||||
end
|
|
||||||
|
|
||||||
for _,r in ipairs(_idf_revs[session_id]) do
|
|
||||||
pin:write(r .. "\n")
|
|
||||||
end
|
|
||||||
pin:close()
|
|
||||||
|
|
||||||
wait(pid)
|
|
||||||
end
|
|
||||||
|
Loading…
Reference in New Issue
Block a user