Comment 1 for bug 58180

Revision history for this message
John A Meinel (jameinel) wrote :

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:
  raise InvalidEntryName(name=name)

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:
if '/' in name:
  raise InvalidEntryName(name=name)

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.