* 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:
Thomas Keller 2010-10-28 19:45:45 +02:00
parent c807c4b734
commit 8a55952204
2 changed files with 62 additions and 46 deletions

View File

@ -34,22 +34,23 @@ 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({
["start"] = function (session_id)
_idf_revs[session_id] = {} _idf_revs[session_id] = {}
end return "continue",nil
end,
function note_netsync_revision_received(new_id, revision, certs, session_id) ["revision_received"] = function (new_id, revision, certs, session_id)
table.insert(_idf_revs[session_id], new_id) table.insert(_idf_revs[session_id], new_id)
end return "continue",nil
end,
function note_netsync_end (session_id, ...) ["end"] = function (session_id, ...)
if table.getn(_idf_revs[session_id]) == 0 then if table.getn(_idf_revs[session_id]) == 0 then
return return "continue",nil
end end
local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%"); local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%");
if pid == -1 then if pid == -1 then
print("could execute %%MTNPOSTPUSH%%") print("could not execute %%MTNPOSTPUSH%%")
return return
end end
@ -59,5 +60,11 @@ function note_netsync_end (session_id, ...)
pin:close() pin:close()
wait(pid) wait(pid)
end return "continue",nil
end
})
--
-- Load additional local hooks, in case they exist
--
include(get_confdir() .. "/hooks.lua")

View File

@ -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,22 +48,23 @@ 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({
["start"] = function (session_id)
_idf_revs[session_id] = {} _idf_revs[session_id] = {}
end return "continue",nil
end,
function note_netsync_revision_received(new_id, revision, certs, session_id) ["revision_received"] = function (new_id, revision, certs, session_id)
table.insert(_idf_revs[session_id], new_id) table.insert(_idf_revs[session_id], new_id)
end return "continue",nil
end,
function note_netsync_end (session_id, ...) ["end"] = function (session_id, ...)
if table.getn(_idf_revs[session_id]) == 0 then if table.getn(_idf_revs[session_id]) == 0 then
return return "continue",nil
end end
local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%"); local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%");
if pid == -1 then if pid == -1 then
print("could execute %%MTNPOSTPUSH%%") print("could not execute %%MTNPOSTPUSH%%")
return return
end end
@ -72,4 +74,11 @@ function note_netsync_end (session_id, ...)
pin:close() pin:close()
wait(pid) wait(pid)
end return "continue",nil
end
})
--
-- Load additional local hooks, in case they exist
--
include(get_confdir() .. "/hooks.lua")