monotone-devel
[Top][All Lists]
Advanced

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

[Monotone-devel] Default get_preferred_merge3_command -- converting to C


From: Steven E. Harris
Subject: [Monotone-devel] Default get_preferred_merge3_command -- converting to Cygwin paths
Date: Wed, 01 Feb 2006 09:49:02 -0800
User-agent: Gnus/5.110004 (No Gnus v0.4) XEmacs/21.4.13 (cygwin32)

For the first time I'm facing a 'monotone propagate' operation that
requires some interactive merging. I'd like to use XEmacs with ediff
for this purpose. The default hook get_preferred_merge3_command looks
like it's set up to respect this desire, but it seems to be rejecting
XEmacs as a candidate editor.

I'm running monotone in a bash shell on Cygwin atop Windows XP. My
XEmacs is a Cygwin build. Here is some shell interaction to
demonstrate the problem, reformatted for width:

$ mt --version
monotone 0.25 (base revision: unknown)

$ echo $EDITOR
xemacs

$ which xemacs
/usr/local/bin/i686-pc-cygwin/xemacs

$ mt propagate source-branch dest-branch
monotone: propagating source-branch -> dest-branch
monotone: [source] 97edf3dd1535d700bd5f29eaecdd0f4e7dd15eb5
monotone: [target] 1e7cd53ba6f95e9d09ea928131532c6d1617474d
monotone: common ancestor fbd8ff4261ff1866125a06b1076212c8356dfaa8 
address@hidden 2006-01-17T21:01:38 found
monotone: trying 3-way merge
monotone: help required for 3-way merge
monotone: [ancestor] some-file.txt
monotone: [    left] some-file.txt
monotone: [   right] some-file.txt
monotone: [  merged] some-file.txt
No external 3-way merge command found.
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,
or add a 3-way merge program to your path.

monotone: misuse: merge of 'some-file.txt' :
  '597d6861d971ed3401d6714205c8a58794dc49fd' ->
    'a5f10a3de154c104c2670372caef23ad7b744bd2' vs
    'afeb3034d35a04c80f8f97b285b7589482743cb5' failed


Eyeing the default get_preferred_merge3_command hook, I suspect that
it's failing around this condition:

  program_exists_in_path ("xemacs")

I can't figure out any way to get inside one of these hooks to trace
execution and inspect the return values.

I tried setting EDITOR to "vim" and, to my surprise, monotone was able
to fire up vim and start the merge. I just can't figure out what I'm
looking at with the three vertical panes, while ediff's merge
interface is second-nature to me.

Well, I got this far and realized that my "xemacs" program is really
just a symbolic link to "xemacs-21.4.3.exe". Apparently Lua doesn't
respect symbolic links to executables. I copied xemacs-21.4.3.exe to
xemacs.exe, reran the 'monotone propagate' operation, and XEmacs
started up just fine.

However, the problem then came down to the paths supplied to the three
files to be examined. The paths are absolute Windows paths, but my
Cygwin XEmacs needs Cygwin paths, or possibly paths relative to the
current working directory.

I tried to cook up a Lua function that would convert the Windows paths
to Cygwin paths using the 'cygpath' function. Unfortunately,
monotone's Lua is lacking the io.popen function, so capturing the
output of cygpath is more difficult than need be.

Here are my first attempts. Keep in mind I've never written any Lua
before.

,----[ io.popen version -- untested ]
| function convert_from_native_path_with_popen(path)
|    local converted_path = nil
| 
|    local stream, error_string = io.popen("cygpath -u")
|    if stream then
|       converted_path = stream:read()
|       stream:close()
|    else
|       print( error_string )
|    end
| 
|    return converted_path
| end
`----


,----[ Temporary file/execute version -- doesn't work ]
| function convert_from_native_path(path)
|    local converted_path = nil
| 
|    local tmp, tname = temp_file()
|    if (tmp ~= nil) then
|       io.close(tmp)
|       if (execute("cygpath", "-u", path, ">", tname) ~= 0) then
|          io.write("Error running cygpath.\n")
|       else
|          tmp = io.open(tname, "r")
|          if (tmp ~= nil) then
|             converted_path = tmp:read()
|             io.close(tmp)
|          end
|       end
|       os.remove(tname)
|    end
| 
|    return converted_path
| end
`----

The first problem with the temporary file/execute version is the
redirection operator ">"; cygpath winds up seeing ">" as another file
name to translate, or at least that's what it looks like it's doing.

Can anyone offer a recipe to capture the output of a shell command
like cygpath? More generally, can anyone offer a means to use XEmacs
on Cygwin as the merge editor? I may be able to solve the latter if I
can get more assistance with the former.

-- 
Steven E. Harris





reply via email to

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