/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

Fix ChrootTransportDecorator's clone to pass less surprising offsets to the decorated transport's clone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
    return scheme + '://' + '/'.join(path)
158
158
 
159
159
 
 
160
def joinpath(base, *args):
 
161
    """Join URL path segments to a URL path segment.
 
162
    
 
163
    This is somewhat like osutils.joinpath, but intended for URLs.
 
164
 
 
165
    XXX: this duplicates some normalisation logic, and also duplicates a lot of
 
166
    path handling logic that already exists in some Transport implementations.
 
167
    We really should try to have exactly one place in the code base responsible
 
168
    for combining paths of URLs.
 
169
    """
 
170
    if base == '/':
 
171
        path = ['']
 
172
    else:
 
173
        path = base.split('/')
 
174
    for arg in args:
 
175
        if arg.startswith('/'):
 
176
            path = []
 
177
        for chunk in arg.split('/'):
 
178
            if chunk == '.':
 
179
                continue
 
180
            elif chunk == '..':
 
181
                if path == ['']:
 
182
                    raise errors.InvalidURLJoin('Cannot go above root',
 
183
                            base, args)
 
184
                path.pop()
 
185
            else:
 
186
                path.append(chunk)
 
187
    if path == ['']:
 
188
        return '/'
 
189
    else:
 
190
        return '/'.join(path)
 
191
 
 
192
 
160
193
# jam 20060502 Sorted to 'l' because the final target is 'local_path_from_url'
161
194
def _posix_local_path_from_url(url):
162
195
    """Convert a url like file:///path/to/foo into /path/to/foo"""