~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-07-23 17:00:27 UTC
  • mfrom: (4555.2.3 1.18-relpath-394227)
  • Revision ID: pqm@pqm.ubuntu.com-20090723170027-0tfrsqpe3tiqnpcb
(jam) Fix bug #394227,
        prevent osutils.relpath() from going into an infinite loop.

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