~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http.py

  • Committer: Robert Collins
  • Date: 2005-10-18 13:11:57 UTC
  • mfrom: (1185.16.72) (0.2.1)
  • Revision ID: robertc@robertcollins.net-20051018131157-76a9970aa78e927e
Merged Martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib.branch import Branch
29
29
from bzrlib.trace import mutter
30
30
 
31
 
# velocitynet.com.au transparently proxies connections and thereby
32
 
# breaks keep-alive -- sucks!
33
 
 
34
31
 
35
32
def get_url(url):
36
33
    import urllib2
78
75
        This can be supplied with a string or a list
79
76
        """
80
77
        if isinstance(relpath, basestring):
81
 
            relpath = [relpath]
 
78
            relpath_parts = relpath.split('/')
 
79
        else:
 
80
            # TODO: Don't call this with an array - no magic interfaces
 
81
            relpath_parts = relpath[:]
 
82
        if len(relpath_parts) > 1:
 
83
            if relpath_parts[0] == '':
 
84
                raise ValueError("path %r within branch %r seems to be absolute"
 
85
                                 % (relpath, self._path))
 
86
            if relpath_parts[-1] == '':
 
87
                raise ValueError("path %r within branch %r seems to be a directory"
 
88
                                 % (relpath, self._path))
82
89
        basepath = self._path.split('/')
83
90
        if len(basepath) > 0 and basepath[-1] == '':
84
91
            basepath = basepath[:-1]
85
 
 
86
 
        for p in relpath:
 
92
        for p in relpath_parts:
87
93
            if p == '..':
88
 
                if len(basepath) < 0:
 
94
                if len(basepath) == 0:
89
95
                    # In most filesystems, a request for the parent
90
96
                    # of root, just returns root.
91
97
                    continue
92
 
                if len(basepath) > 0:
93
 
                    basepath.pop()
94
 
            elif p == '.':
 
98
                basepath.pop()
 
99
            elif p == '.' or p == '':
95
100
                continue # No-op
96
101
            else:
97
102
                basepath.append(p)
98
 
 
99
103
        # Possibly, we could use urlparse.urljoin() here, but
100
104
        # I'm concerned about when it chooses to strip the last
101
105
        # portion of the path, and when it doesn't.