~ubuntu-branches/debian/squeeze/bzr/squeeze

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Bazaar Package Importer
  • Author(s): John Francesco Ferlito
  • Date: 2009-11-04 22:47:44 UTC
  • mfrom: (1.4.2 upstream) (9.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091104224744-axzbc1qj8of7m8lk
Tags: 2.0.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1040
1040
 
1041
1041
    s = []
1042
1042
    head = rp
1043
 
    while len(head) >= len(base):
 
1043
    while True:
 
1044
        if len(head) <= len(base) and head != base:
 
1045
            raise errors.PathNotChild(rp, base)
1044
1046
        if head == base:
1045
1047
            break
1046
 
        head, tail = os.path.split(head)
 
1048
        head, tail = split(head)
1047
1049
        if tail:
1048
 
            s.insert(0, tail)
1049
 
    else:
1050
 
        raise errors.PathNotChild(rp, base)
 
1050
            s.append(tail)
1051
1051
 
1052
1052
    if s:
1053
 
        return pathjoin(*s)
 
1053
        return pathjoin(*reversed(s))
1054
1054
    else:
1055
1055
        return ''
1056
1056
 
1083
1083
    bit_iter = iter(rel.split('/'))
1084
1084
    for bit in bit_iter:
1085
1085
        lbit = bit.lower()
1086
 
        for look in _listdir(current):
 
1086
        try:
 
1087
            next_entries = _listdir(current)
 
1088
        except OSError: # enoent, eperm, etc
 
1089
            # We can't find this in the filesystem, so just append the
 
1090
            # remaining bits.
 
1091
            current = pathjoin(current, bit, *list(bit_iter))
 
1092
            break
 
1093
        for look in next_entries:
1087
1094
            if lbit == look.lower():
1088
1095
                current = pathjoin(current, look)
1089
1096
                break
1093
1100
            # the target of a move, for example).
1094
1101
            current = pathjoin(current, bit, *list(bit_iter))
1095
1102
            break
1096
 
    return current[len(abs_base)+1:]
 
1103
    return current[len(abs_base):].lstrip('/')
1097
1104
 
1098
1105
# XXX - TODO - we need better detection/integration of case-insensitive
1099
1106
# file-systems; Linux often sees FAT32 devices (or NFS-mounted OSX