Merge lp:~jspashett/bzr/322807_add_root_drive_windows into lp:bzr

Proposed by Jason Spashett
Status: Rejected
Rejected by: John A Meinel
Proposed branch: lp:~jspashett/bzr/322807_add_root_drive_windows
Merge into: lp:bzr
Diff against target: 12 lines
1 file modified
bzrlib/osutils.py (+1/-1)
To merge this branch: bzr merge lp:~jspashett/bzr/322807_add_root_drive_windows
Reviewer Review Type Date Requested Status
John A Meinel Needs Fixing
Review via email: mp+12842@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jason Spashett (jspashett) wrote :

In _cicp_canonical_relpath (osutils.py)

This is done:
return current[len(abs_base)+1:]

Which does not work on windows, where abs_base = x:/ in this case a '/' is not appended since it already ends with one, making len(abs_base)+1 incorrect in this case.

Change to use os.path.split instead.

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

This turns out to not be the right fix.

Specifically, 'canonical_relpath' is meant to work even for nested values. For example:

canonical_relpath('C:/foo', 'C:/foo/bar/baz')
should return 'bar/baz', while your form only returns "baz".

There is also a few other things, like getting better testing of this function. It is slightly tested in bzrlib/tests/test_osutils.py but not particularly well (only indirectly via canonical_relpath() tests.)

When I started looking at writing tests, I then found that it requires 'abs_base' to exist, or you get an exception during list_dir(). Which is somewhat reasonable for real-uses, but makes testing harder than it needs to be.

So I'll go ahead and look at this for a bit, and propose an alternative patch, if that is ok with you.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/osutils.py'
2--- bzrlib/osutils.py 2009-09-19 01:33:10 +0000
3+++ bzrlib/osutils.py 2009-10-04 13:05:28 +0000
4@@ -1142,7 +1142,7 @@
5 # the target of a move, for example).
6 current = pathjoin(current, bit, *list(bit_iter))
7 break
8- return current[len(abs_base)+1:]
9+ return os.path.split(current)[1]
10
11 # XXX - TODO - we need better detection/integration of case-insensitive
12 # file-systems; Linux often sees FAT32 devices (or NFS-mounted OSX