/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/transport/memory.py

  • Committer: Robert Collins
  • Date: 2006-09-16 06:44:47 UTC
  • mfrom: (2014 +trunk)
  • mto: (2017.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2018.
  • Revision ID: robertc@robertcollins.net-20060916064447-99a2987e5485b5ea
Merge from bzr.dev, fixing found bugs handling 'has('/')' in MemoryTransport and SFTP transports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        if url[-1] != '/':
60
60
            url = url + '/'
61
61
        super(MemoryTransport, self).__init__(url)
62
 
        self._cwd = url[url.find(':') + 3:]
 
62
        split = url.find(':') + 3
 
63
        self._scheme = url[:split]
 
64
        self._cwd = url[split:]
63
65
        # dictionaries from absolute path to file mode
64
66
        self._dirs = {'/':None}
65
67
        self._files = {}
67
69
 
68
70
    def clone(self, offset=None):
69
71
        """See Transport.clone()."""
70
 
        if offset is None or offset == '':
71
 
            return copy(self)
72
 
        segments = offset.split('/')
73
 
        cwdsegments = self._cwd.split('/')[:-1]
74
 
        while len(segments):
75
 
            segment = segments.pop(0)
76
 
            if segment == '.':
77
 
                continue
78
 
            if segment == '..':
79
 
                if len(cwdsegments) > 1:
80
 
                    cwdsegments.pop()
81
 
                continue
82
 
            cwdsegments.append(segment)
83
 
        url = self.base[:self.base.find(':') + 3] + '/'.join(cwdsegments) + '/'
 
72
        path = self._combine_paths(self._cwd, offset)
 
73
        if len(path) == 0 or path[-1] != '/':
 
74
            path += '/'
 
75
        url = self._scheme + path
84
76
        result = MemoryTransport(url)
85
77
        result._dirs = self._dirs
86
78
        result._files = self._files
236
228
        relpath = urlutils.unescape(relpath)
237
229
        if relpath.find('..') != -1:
238
230
            raise AssertionError('relpath contains ..')
 
231
        if relpath == '':
 
232
            return '/'
 
233
        if relpath[0] == '/':
 
234
            return relpath
239
235
        if relpath == '.':
240
236
            if (self._cwd == '/'):
241
237
                return self._cwd