Download PDF - Monotone

Transcript
Appendix A: Default hooks
275
function merge3 (anc_path, left_path, right_path, merged_path, ancestor, left, right)
local ret = nil
local tbl = {}
tbl.anc_path = anc_path
tbl.left_path = left_path
tbl.right_path = right_path
tbl.merged_path = merged_path
tbl.afile = nil
tbl.lfile = nil
tbl.rfile = nil
tbl.outfile = nil
tbl.meld_exists = false
tbl.lfile = write_to_temporary_file (left, "left", "r+b")
tbl.afile = write_to_temporary_file (ancestor, "ancestor", "r+b")
tbl.rfile = write_to_temporary_file (right, "right", "r+b")
tbl.outfile = write_to_temporary_file ("", "merged", "r+b")
if tbl.lfile ~= nil and tbl.rfile ~= nil and tbl.afile ~= nil and tbl.outfile ~= nil
then
local cmd,mkey = get_preferred_merge3_command (tbl)
if cmd ~=nil
then
io.write ("mtn: " .. string.format(gettext("executing external 3-way merge via \"
ret = cmd (tbl)
if not ret then
ret = nil
else
ret = read_contents_of_file (ret, "rb")
if string.len (ret) == 0
then
ret = nil
end
end
else
if mkey then
io.write (string.format("The possible commands for the "..mkey.." merger aren’t avai
"You may want to check that $MTN_MERGE or the lua variable ‘merger’ is set\n
"to something available.
If you want to use vim or emacs, you can also\n"
"set $EDITOR to something appropriate.\n"))
else
io.write (string.format("No external 3-way merge command found.\n"..
"You may want to check that $EDITOR is set to an editor that supports 3-way\
"merge, set this explicitly in your get_preferred_merge3_command hook,\n"..
"or add a 3-way merge program to your path.\n"))