[PATCH V4] test-walk: enable for Windows

Adrian Buehlmann adrian at cadifra.com
Fri Jun 15 18:19:45 CDT 2012


On 2012-06-15 21:11, timeless wrote:
> i've been meaning to mention that "glob:glob" isn't precisely an
> unusable thing on Windows.
> 
> NTFS uses ":" as the stream delimiter. The main use for this feature
> was support for Mac OS Classic "Resource Forks", but it was also used
> for file meta data (MS Office Documents, Audio/Video files).

Thanks for the hint.

So we can have some fun with

>>> f = open('foo:bar', 'wb')
>>> f.write('hello\n')
>>> f.close()

as that silently "succeeds", but creates a file foo with stream bar, containing
"hello\n".

Rename to hello:world raises

>>> import os
>>> os.rename("foo", "baz")
>>> os.rename("baz", "hello:world")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect

Reading from the stream will also miraculously "work":

>>> f = open('baz:bar')
>>> print f.read(),
hello

I can even lstat it

>>> os.lstat('baz:bar')
nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=6L, st_atime=1339800635L, st_mtime=1339800657L, st_ctime=1339800635L)

But there is no such file

>>> os.listdir('.')
['baz']





More information about the Mercurial-devel mailing list