diff --git a/src/IDF/Plugin/SyncMonotone/monotonerc-auth.tpl b/src/IDF/Plugin/SyncMonotone/monotonerc-auth.tpl index daf3307..7e5ff8c 100644 --- a/src/IDF/Plugin/SyncMonotone/monotonerc-auth.tpl +++ b/src/IDF/Plugin/SyncMonotone/monotonerc-auth.tpl @@ -34,30 +34,37 @@ end -- let IDF know of new arriving revisions to fill its timeline -- _idf_revs = {} -function note_netsync_start(session_id) - _idf_revs[session_id] = {} -end +push_hook_functions({ + ["start"] = function (session_id) + _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) - table.insert(_idf_revs[session_id], new_id) -end + local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%"); + if pid == -1 then + print("could not execute %%MTNPOSTPUSH%%") + return + end -function note_netsync_end (session_id, ...) - if table.getn(_idf_revs[session_id]) == 0 then - return - end - - local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%"); - if pid == -1 then - print("could execute %%MTNPOSTPUSH%%") - return - end + for _,r in ipairs(_idf_revs[session_id]) do + pin:write(r .. "\n") + end + pin:close() - for _,r in ipairs(_idf_revs[session_id]) do - pin:write(r .. "\n") + wait(pid) + return "continue",nil end - pin:close() - - wait(pid) -end +}) +-- +-- Load additional local hooks, in case they exist +-- +include(get_confdir() .. "/hooks.lua") diff --git a/src/IDF/Plugin/SyncMonotone/monotonerc-noauth.tpl b/src/IDF/Plugin/SyncMonotone/monotonerc-noauth.tpl index c0c0050..e59aa04 100644 --- a/src/IDF/Plugin/SyncMonotone/monotonerc-noauth.tpl +++ b/src/IDF/Plugin/SyncMonotone/monotonerc-noauth.tpl @@ -31,7 +31,8 @@ function get_remote_automate_permitted(key_identity, command, options) "leaves", "ancestry_difference", "toposort", "erase_ancestors", "descendents", "ancestors", "heads", "get_file_of", "get_file", "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 @@ -47,29 +48,37 @@ end -- let IDF know of new arriving revisions to fill its timeline -- _idf_revs = {} -function note_netsync_start(session_id) - _idf_revs[session_id] = {} -end - -function note_netsync_revision_received(new_id, revision, certs, session_id) - table.insert(_idf_revs[session_id], new_id) -end +push_hook_functions({ + ["start"] = function (session_id) + _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_end (session_id, ...) - if table.getn(_idf_revs[session_id]) == 0 then - return - end + local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%"); + if pid == -1 then + print("could not execute %%MTNPOSTPUSH%%") + return + end - local pin,pout,pid = spawn_pipe("%%MTNPOSTPUSH%%", "%%PROJECT%%"); - if pid == -1 then - print("could execute %%MTNPOSTPUSH%%") - return - end + for _,r in ipairs(_idf_revs[session_id]) do + pin:write(r .. "\n") + end + pin:close() - for _,r in ipairs(_idf_revs[session_id]) do - pin:write(r .. "\n") + wait(pid) + return "continue",nil end - pin:close() +}) - wait(pid) -end +-- +-- Load additional local hooks, in case they exist +-- +include(get_confdir() .. "/hooks.lua")