To summarize
In _BufferList::current there are checks like
abspath(bufname("%")) == abspath(vim.buffers[i].name)
or, in my case, simplified
abspath('/Users/err') == abspath('c:/Users/err')
which specifically is
'C:\Users\err' == 'c:\Users\err'
and this test fails because of drive letter case. It appears that abspath
preserves the case of a driver letter that is passed in, and uses upper
case when it adds a drive letter.
A fix is to do
bufname = ap(vim.buffers[vim.eval('bufnr("%")')].name)
at the entry to current and not use bufname("%"). Doing this, abspath
is no longer needed, the vim doc says buffers[].name is full path, so...
BTW, if there is concern about symlinks... then realpath should be used.
This is further simplified by using integers. The function becomes
bufnr = int(vim.eval('bufnr("%")'))
return Buffer(bufnr)
I don't know why this hasn't shown up for others previously.
I've just started using Splice. I'm using Cygwin, win7, though both hg and gvim
are native win apps. I think cygwin plays into it, but I can't tell why.
I'll investigate further and I'll set up a submit a pull request over the next few weeks.
Keeping the strings, it looks like
bufname = vim.buffers[int(vim.eval('bufnr("%")'))].name
if bufname == self.original.name:
return self.original
elif bufname == self.one.name:
return self.one
elif bufname == self.two.name:
return self.two
elif bufname == self.result.name:
return self.result
Following is gory detail, summarizing my explorations...
given:
splice.executable = an essentially empty .bat file
splice.args = $base $local $other $output,
the output is:
...
merging f00
"c:\users\err\appdata\local\temp\f00base.kqpucf"
"c:\users\err\appdata\local\temp\f00local.ym6qvj"
"c:\users\err\appdata\local\temp\f00~other.dyblkj"
"C:\f\play\mercurial\merge2\c0\f00"
2 files updated, 1 files merged, 0 files removed, 0 files unresolved
Note drive letter case is inconsistent, the output file has upper case "C".
F: is mounted on C: as f, so C:/f goes into the F: drive. That might have
something to do with it.
And from gvim, there is
:args
[/Users/err/AppData/Local/Temp/f00~base.ppb8mc]
/Users/err/AppData/Local/Temp/f00~local.hoolxp
/Users/err/AppData/Local/Temp/f00~other.jvwbfy
f00
:py import vim
:py for b in vim.buffers: print(b.name)
c:/Users/err/AppData/Local/Temp/f00~base.ppb8mc
c:/Users/err/AppData/Local/Temp/f00~local.hoolxp
c:/Users/err/AppData/Local/Temp/f00~other.jvwbfy
C:/f/play/mercurial/merge2/c0/f00
BUT
:echo bufname("%")
/Users/err/AppData/Local/Temp/f00~local.rorffx
:echo bufname("%")
f00
So vim.buffers[].name may be different from bufname("%")
It's curious that the .bat file shows a full path for f00,
but :args and bufname only shows the basename.
In a trivial python program that invokes abspath on its arguments
and prints before/after for each argument
$ ./apTest /Users/err c:/Users/err
=== using F:/pf/Python27/python
('/Users/err', 'C:\Users\err')
('c:/Users/err', 'c:\Users\err')
notice that abspath preserves the lower case "c:".
This all comes together in splicelib/util/bufferlib.py::_BufferList::current.
In _BufferList::current there are checks like
abspath(bufname("%")) == abspath(vim.buffers[i].name)
or simplified
abspath('/Users/err') == abspath('c:/Users/err')
which is
'c:\Users\err' == 'C:\Users\err'
and this test fails because of drive letter case.
I guess the discrepancy enters into it because vim's buffer[].name
is fname converted to an absolute path, forcing the drive letter to upper.