[MERGE] Win32 fixes
John Arbash Meinel
john at arbash-meinel.com
Fri Apr 21 14:38:43 BST 2006
Aaron Bentley wrote:
> Here are some fixes for win32. My ongoing work can be found here:
> http://panoramicfeedback.com/opensource/bzr/repo/win32fixes/
>
> 1. LocalTransport.put on win32 detects illegal paths and raises an
> appropriate exception. This affects weave repositories, but should not
> affect knit ones. Tests which use illegal paths are skipped.
>
> 2. Tests of file executability use the only cross-platform API for
> setting file executability: TreeTransform
>
> 3. LocalTransport.relpath does not strip trailing slashes from drive
> roots like 'C:/'
>
> But I really, really think LocalTransport should be using URLs like
> file://C|/, and then we can have uniform rules.
>
> Aaron
+1 from me, with 1 minor comment:
def has(self, relpath):
return os.access(self.abspath(relpath), os.F_OK)
@@ -104,6 +101,8 @@
path = relpath
try:
path = self.abspath(relpath)
+ if sys.platform=="win32" and ('<' in path or '>' in path) :
+ raise IllegalPath(path)
fp = AtomicFile(path, 'wb', new_mode=mode)
except (IOError, OSError),e:
self._translate_error(e, path)
There are a *lot* more illegal characters than just '<>'. The list I
always remember is '\/?<>":*|'
I'm guessing that a regex might be the easiest way to detect it.
Something like:
_illegalWindowsRE = re.compile(r'\\|/|\?|<|>|"|:|\*|\|')
...
if (sys.platform in ('win32', 'cygwin')
and _illegalWindowsRE.search(path)):
raise IllegalPath(path)
Now, I also suppose that the biggest problem with the above regex is
that ':' is allowed in the path, but only as the drive separator. (Or
alternatively as a stream separator in NTFS, sort of like resources in Mac).
So we either need to treat ':' specially (as in make sure it is in the
beginning, but doesn't exist in the rest of the path). Or just punt for now.
But since baz-import uses 'Arch:foo' it would be a lot nicer for the
user to get an IllegalPath exception, than some random OS error. They
will likely get it anyway, because of the <> in arch ids for
directories, but it is a small issue of when they get the correct error
message.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060421/9df71889/attachment.pgp
More information about the bazaar
mailing list