monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] [PATCH] add xemacs and rcs merge commands to lua merge2


From: Derek Scherger
Subject: [Monotone-devel] [PATCH] add xemacs and rcs merge commands to lua merge2/merge3 hooks; fix bug 8550
Date: Mon, 19 Apr 2004 23:09:34 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040225

This patch adds support for xemacs to the merge2 and merge3 hooks and support for the merge command included with the gnu rcs package to the merge3 hook which allows for cvs style merges with conflict markers.

Note that using the rcs merge command will commit a file with conflict markers requiring further edits to resolve the conflict. CVS users should be familiar with editing files that contain these conflict markers.

It also fixes bug 8550 and issues a message if no external merge tools are 
available.
--
Cheers,
Derek

--- std_hooks.lua
+++ std_hooks.lua
@@ -137,16 +137,21 @@

 -- merger support

-function merge2_emacs_cmd(lfile, rfile, outfile)
+function merge2_emacs_cmd(emacs, lfile, rfile, outfile)
    local elisp = "'(ediff-merge-files \"%s\" \"%s\" nil \"%s\")'"
-   local cmd_fmt = "emacs -no-init-file -eval " .. elisp
-   return string.format(cmd_fmt, lfile, rfile, outfile)
+   local cmd_fmt = "%s -no-init-file -eval " .. elisp
+   return string.format(cmd_fmt, emacs, lfile, rfile, outfile)
 end

-function merge3_emacs_cmd(lfile, afile, rfile, outfile)
+function merge3_emacs_cmd(emacs, lfile, afile, rfile, outfile)
    local elisp = "'(ediff-merge-files-with-ancestor \"%s\" \"%s\" \"%s\" nil 
\"%s\")'"
-   local cmd_fmt = "emacs -no-init-file -eval " .. elisp
-   return string.format(cmd_fmt, lfile, rfile, afile, outfile)
+   local cmd_fmt = "%s -no-init-file -eval " .. elisp
+   return string.format(cmd_fmt, emacs, lfile, rfile, afile, outfile)
 end

 function merge2_xxdiff_cmd(lfile, rfile, outfile)
@@ -161,6 +166,11 @@
    return string.format(cmd_fmt .. cmd_opts, lfile, afile, rfile, outfile)
 end

+function merge3_merge_cmd(lfile, afile, rfile, outfile)
+   local cmd_fmt = "merge -p -L left -L ancestor -L right %s %s %s > %s"
+   return string.format(cmd_fmt, lfile, afile, rfile, outfile)
+end
+
 function write_to_temporary_file(data)
    tmp, filename = temp_file()
    if (tmp == nil) then
@@ -203,7 +208,9 @@
       if program_exists_in_path("xxdiff") then
         cmd = merge2_xxdiff_cmd(lfile, rfile, outfile)
       elseif program_exists_in_path("emacs") then
-        cmd = merge2_emacs_cmd(lfile, rfile, outfile)
+        cmd = merge2_emacs_cmd("emacs", lfile, rfile, outfile)
+      elseif program_exists_in_path("xemacs") then
+        cmd = merge2_emacs_cmd("xemacs", lfile, rfile, outfile)
       end

       if cmd ~= nil
@@ -211,6 +213,8 @@
         io.write(string.format("executing external 2-way merge command: %s\n", 
cmd))
         os.execute(cmd)
         data = read_contents_of_file(outfile)
+      else
+        io.write("no external 2-way merge command found")
       end
    end

@@ -239,10 +241,14 @@
       outfile ~= nil
    then
       local cmd = nil
-      if program_exists_in_path("xxdiff") then
+      if program_exists_in_path("merge") then
+         cmd = merge3_merge_cmd(lfile, afile, rfile, outfile)
+      elseif program_exists_in_path("xxdiff") then
         cmd = merge3_xxdiff_cmd(lfile, afile, rfile, outfile)
       elseif program_exists_in_path("emacs") then
-        cmd = merge3_emacs_cmd(lfile, afile, rfile, outfile)
+        cmd = merge3_emacs_cmd("emacs", lfile, afile, rfile, outfile)
+      elseif program_exists_in_path("xemacs") then
+        cmd = merge3_emacs_cmd("xemacs", lfile, afile, rfile, outfile)
       end

       if cmd ~= nil
@@ -250,6 +254,8 @@
         io.write(string.format("executing external 3-way merge command: %s\n", 
cmd))
         os.execute(cmd)
         data = read_contents_of_file(outfile)
+      else
+        io.write("no external 3-way merge command found")
       end
    end





reply via email to

[Prev in Thread] Current Thread [Next in Thread]