~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

Fix ChrootTransportDecorator's abspath method to be consistent with its clone
method when dealing with relpaths that start with "/".

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
    else:
131
131
        path = base.split('/')
132
132
 
 
133
    if scheme is not None and len(path) >= 1:
 
134
        host = path[:2]
 
135
        path = path[2:]
 
136
    else:
 
137
        host = []
133
138
    for arg in args:
134
139
        m = _url_scheme_re.match(arg)
135
140
        if m:
138
143
            # this skips .. normalisation, making http://host/../../..
139
144
            # be rather strange.
140
145
            path = m.group('path').split('/')
 
146
            # set the host and path according to new absolute URL, discarding
 
147
            # any previous values.
 
148
            # XXX: duplicates mess from earlier in this function.  This URL
 
149
            # manipulation code needs some cleaning up.
 
150
            if scheme is not None and len(path) >= 1:
 
151
                host = path[:2]
 
152
                path = path[2:]
 
153
            else:
 
154
                host = []
141
155
        else:
142
 
            for chunk in arg.split('/'):
143
 
                if chunk == '.':
144
 
                    continue
145
 
                elif chunk == '..':
146
 
                    if len(path) >= 2:
147
 
                        # Don't pop off the host portion
148
 
                        path.pop()
149
 
                    else:
150
 
                        raise errors.InvalidURLJoin('Cannot go above root',
151
 
                                base, args)
152
 
                else:
153
 
                    path.append(chunk)
 
156
            path = '/'.join(path)
 
157
            path = joinpath(path, arg)
 
158
            path = path.split('/')
 
159
    if host:
 
160
        if path and path[0] == '':
 
161
            del path[0]
 
162
        path = host + path
154
163
 
155
164
    if scheme is None:
156
165
        return '/'.join(path)