~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Martin Pool
  • Date: 2006-03-10 06:09:25 UTC
  • mto: This revision was merged to the branch mainline in revision 1609.
  • Revision ID: mbp@sourcefrog.net-20060310060925-7b26b6236c7cd6e5
[patch] LocalTransport.list_dir should return url-quoted strings (ddaa)

When trying to convert a Launchpad branch into metadir format, I hit a
bug caused by incorrect url quoting in LocalTransport (one of weaves has
a '/' in its id).

The attached patch fix LocalTransport.list_dir to allow converting
Launchpad to metadir. It should probably be augmented by a number of
test cases, and probably overlaps wildly with John's local transport
quoting branch. But I'm posting it here for the record.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    def __init__(self, base):
36
36
        """Set the base path where files will be stored."""
37
37
        if base.startswith('file://'):
38
 
            base = base[7:]
 
38
            base = base[len('file://'):]
39
39
        # realpath is incompatible with symlinks. When we traverse
40
40
        # up we might be able to normpath stuff. RBC 20051003
41
41
        base = normpath(abspath(base))
111
111
        """Iter the relative paths of files in the transports sub-tree."""
112
112
        queue = list(self.list_dir(u'.'))
113
113
        while queue:
114
 
            relpath = urllib.quote(queue.pop(0))
 
114
            relpath = queue.pop(0)
115
115
            st = self.stat(relpath)
116
116
            if S_ISDIR(st[ST_MODE]):
117
117
                for i, basename in enumerate(self.list_dir(relpath)):
222
222
        WARNING: many transports do not support this, so trying avoid using
223
223
        it if at all possible.
224
224
        """
225
 
        path = relpath
 
225
        path = self.abspath(relpath)
226
226
        try:
227
 
            path = self.abspath(relpath)
228
 
            return os.listdir(path)
 
227
            return [urllib.quote(entry) for entry in os.listdir(path)]
229
228
        except (IOError, OSError),e:
230
229
            self._translate_error(e, path)
231
230