[BUG] MemoryTransport.list_dir('.') broken

John Arbash Meinel john at arbash-meinel.com
Fri Nov 3 21:08:15 GMT 2006


I was trying to write some tests which use MemoryTransport as the
back-end. And one thing that I was testing was that there were no extra
files generated as part of the process, so I was comparing
transport.list_dir('.') against a known list of files.

It turns out that if you are in the root directory of the
MemoryTransport, it strips off an extra character from every filename.

You can test it like this:

>>> import bzrlib.transport
>>> mem = bzrlib.transport.get_transport('memory:///')
>>> mem.put_bytes('file1', 'bytes1\n')
>>> mem.mkdir('dir2')
>>> mem.put_bytes('dir2/file3', 'bytes3\n')
>>> mem.list_dir('dir2')
['file3']
>>> mem._files.keys()
[u'/dir2/file3', u'/file1']
# So far, everything is correct
>>> mem.list_dir('.')
[u'ile1]

The attached bundle provides tests for list_dir, and an appropriate fix.

I think the reason it wasn't exposed in the past, was because the
Transport.list_dir() tests always worked in a subdir, because sftp
created clutter in the working directory. But since we've moved home/ to
be separate from work/, we don't need to do that anymore.

The patch also simplifies the list_dir() implementation, so that we
don't have 2 loops doing the same thing.

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: memory_list_dir.patch
Type: text/x-patch
Size: 4137 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061103/f4fef6c2/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061103/f4fef6c2/attachment.pgp 


More information about the bazaar mailing list