Path fun on Windows

Adrian Buehlmann adrian at cadifra.com
Wed Jun 6 13:37:08 UTC 2012


On 2012-06-06 14:39, Mads Kiilerich wrote:
> On 06/06/12 14:26, Adrian Buehlmann wrote:
>> Also, I think we do want to be exposed to real Windows paths when
>> testing on Windows - depending on the virtual, made-up unix-path crotch
>> provided by MSYS won't help us much. Other than making us dependent on
>> that crotch.
>>
>> Also, I fear we would then be exposed to the totally artificial MSYS
>> paths like
>>
>>    /c/Users/adi
>>
>> etc., which might confuse mercurial a whole lot, as such paths are
>> clearly not expected on a system where os.name == 'nt'.
> 
> But ... msys bash will always convert such paths to real windows paths 
> when invoking external programs, using the rules on the page you found - 
> http://www.mingw.org/wiki/Posix_path_conversion . Or ???

You're probably right. Thanks for insisting.

Some quick testing after having applied

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -614,8 +614,6 @@
     script = []
     if options.debug:
         script.append('set -x\n')
-    if os.getenv('MSYSTEM'):
-        script.append('alias pwd="pwd -W"\n')
     for n, l in enumerate(t):
         if not l.endswith('\n'):
             l += '\n'

inside a *.t file yields

   >>> import os; print os.getcwd()
+  $TESTTMP
   $ pwd
+  /tmp/hgtests.qfl8xz/test-a.t
   $ pwd | python -c "import sys; print sys.stdin.read(),"
+  /tmp/hgtests.qfl8xz/test-a.t
   $ python -c "import sys; print sys.argv[1]" `pwd`
+  $TESTTMP

For the perspective of the script-level, it might even be better to have
to deal with unix-like paths only, and let MSYS bash translate the path
as late as possible.

I think it would be worth a try and seeing how it works with removing
the pwd -W alias.

Maybe we then need to find a way to map tempdir paths in the output
lines like

  /tmp/hgtests.qfl8xz/test-a.t

back to

  $TESTTMP

Or perhaps we should simply avoid writing such paths to the output.



More information about the Mercurial-devel mailing list