support filenames like C:\FOO.TXT
Bug #58180 reported by
David Allouche
This bug report is a duplicate of:
Bug #81844: backslash in filename causes InvalidEntryName etc.
Edit
Remove
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
bzr init foo ;cd foo
touch 'C:\FOO.TXT' ; bzr add
<traceback>
InvalidEntryName: Invalid entry name: C:\FOO.TXT
Such a file name can be found in the unixodbc CVS repository:
:pserver:<email address hidden>
That is requested for a VCS import in Launchpad:
https:/
CVS supports such file names fine (at least on Linux). This import cannot be completed until bzr supports them as well.
To post a comment you must log in.
The code in question is in bzrlib/inventory.py line 283.
It is trying to trap someone creating an inventory entry that accidentally has a path component as part of its name. Specifically, it is doing:
if '/' in name or '\\' in name: e(name= name)
raise InvalidEntryNam
Now, by this point in the internals of bzr, the path should have been normalized, such that all '\' in the original full path have become '/' internally on Windows.
So we could possibly just change the line to read: e(name= name)
if '/' in name:
raise InvalidEntryNam
Now, on Windows, if we ever tried to checkout this tree, I would expect one of the abspath functions to change the '\' into a '/', and things could get pretty messy.
However, this particular code path is reached every time we read an inventory, so we could abstract it into a function, and then on Windows, if we get a 'name' element that includes a '\', we can raise a nice error, which says that filenames with '\' are not supported on Windows.
And then on Linux, we skip that part of the check.
This becomes just one more incompatibility between Linux checkins and Windows checkouts.
Windows doesn't allow all sorts of characters anyway, so we probably should have something like that in place. To handle all of the other bogus windows chars (<>":\/) are the ones I know about off hand.I'm always looking it up, though, I really should bookmark it.
If someone needs '\' support, it should be pretty straightforward to add it.
Also, if we wanted to be really nice, we could degrade the comment to a warning if not on Windows. So people will know that they have a tree that is invalid on Win.
However, this would be the wrong place to do the warning, because it would be encountered every time the Inventory is being read, whether or not the user is doing anything active on that file.
So I would recommend the warning be easy to generate, and have it as part of 'smart_add_tree()', and other such places.