[MERGE] mv accepts paths containing symlinks #66964

John Arbash Meinel john at arbash-meinel.com
Tue Oct 24 17:23:26 BST 2006


Aaron Bentley wrote:
> John Arbash Meinel wrote:
>>> Aaron Bentley wrote:
>>> What about:
>>> https://launchpad.net/products/bzr/+bug/48444
>>>
>>> Do you think that bug would be affected by this fix?
> 
> Actually, I think my patch is slightly broken in that regard;
> WorkingTree.open_containing should call the standard os.realpath, so
> that it follows sylinks in the actual branch names.
> 
>>> v- This should probably be:
>>>
>>> dirname, basename = os.path.split(path)
>>> osutils.pathjoin(osutils.realpath(dirname), basename)
> 
> I assume we shouldn't be using os.path.split, because osutils has custom
> versions of basename and dirname.  I don't want to use
> osutils.splitpath, because then I have to synthesize the dirname from
> the result.  But since we don't have an equivalent of os.path.split, I
> used osutils.dirname and osutils.basename.

Well, I can give you the specifics and tell you that os.path.split is
fine to use, but I understand your hesitancy.

In fact:

dir, base = os.path.split(path)
osutils.pathjoin(os.path.realpath(dir), base)

^- Should also be fine.

I'm not 100% positive that 'realpath' always does the right thing under
Mac. I know that 'abspath()' was tweaked to do the right thing (by going
through getcwd() which was actually fixed for mac and Unicode
normalization).

Anyway, split() is okay, because it only takes an existing path and
breaks it up, (which is why the code actually uses os.path.dirname and
os.path.basename in some places without any problem).

If you want to add 'split()' to osutils, you are welcome to do so.

> 
>>> Perhaps we should change osutils.??? so that it implements this
>>> behavior, because it would have an effect for lots of other bugs as well.
> 
> I don't think we should provide it under the name 'realpath', because
> it's subtly different[1].  But it would make sense to provide it.

^- I understand. I do think it should be an osutils function, but you
can name it what you like. (follow_early_symlinks_path() :)

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/20061024/67223545/attachment.pgp 


More information about the bazaar mailing list