Path fun on Windows
Adrian Buehlmann
adrian at cadifra.com
Wed Jun 6 12:15:44 UTC 2012
On 2012-06-06 13:35, Eduard-Cristian Stefan wrote:
> On Wed, Jun 6, 2012 at 12:54 PM, Adrian Buehlmann <adrian at cadifra.com> wrote:
>> Now, we have to look at where the path
>>
>> 'c:\\users\\adi\\appdata\\local\\temp\\hgtests.zf5gag\\test-a.t'
>>
>> is coming from. It comes from run-tests.py
>>
>> 1249 tmpdir = tempfile.mkdtemp('', 'hgtests.')
>>
>> which uses Python's mkdtemp() function of the tempfile Python standard
>> library module.
>
> The case can be restored with win32api, if it's available [1]:
>
> win32api.GetLongPathNameW(win32api.GetShortPathName(path))
>
> [1] http://stackoverflow.com/a/7622476/19756
Interesting hint, thanks. I'll probably try playing with that trick.
We already have util.fspath, which uses the also mentioned os.listdir trick.
As a side note, on Windows, there are differences between stat-ing files
and directories. For example, we have a mercurial.win32.samefile()
function, which is specified to work only for file paths - not directories.
BTW, we shouldn't reintroduce depending on win32api, but it shouldn't be
a problem to call the Windows API directly via Python's ctypes (see
mercurial/win32.py).
At the moment, I'm really tempted to kill util.samestat(). That function
can't be implemented on Windows. So basically there can't be such a
thing as util.samestat().
More information about the Mercurial-devel
mailing list