[BUG] transport/memory.py doesn't handle strings

John A Meinel john at arbash-meinel.com
Wed Oct 19 04:01:32 BST 2005


Robert Collins wrote:
> On Tue, 2005-10-18 at 20:39 -0400, Aaron Bentley wrote:
>
...

> Because for f in 'hello' -> h,e,l,l,o
> for f in ['hel', 'lo'] -> hel, lo
> for f in StringIO('hello') -> 'hello'
>
> They are behaving differently. Its interesting that they are all
> iterable, but not really relevant.
>

Well, they do all end up giving you the same string when concatenated.
But I really think we want avoid giving put a bunch of bytes it has to
collect before pushing.
The idea of put is to give the complete contents, which is then shoved
to the remote side.

>
>>>>I'm also concerned that MemoryTransport.clone() returns the exact copy of
>>>>itself. Because one of the fundamental bits of Transport objects is that
>>>>they have a "base" where all paths are given relative to that base.
>>>>
>>>>Since all files and directories are stored inside the dictionary as
>>>>relative paths, clone(offset=".bzr/") will fail. And this type of cloning
>>>>is used in bzrlib/branch.py so that the Store objects have "base" set
>>>>appropriately.
>>>
>>>
>>>In bzrlib/branch.py, cloning at the top is checked for by
>>>'new_transport.base == old_transport.base'. I was duplicating that
>>>interface.
>>
>>There should be a test for transport.base != transport.clone('a').base.
>
>
> Does that mean the branch open_containing code is broken ?

No, I think you just misunderstood what it was doing.

If you give an offset other than ".." you should always get a different
directory. And the directory doesn't have to exist, since we could be
given a non-existent path that we want to start searching from.

The test suite should be extended to test the clone() support, such that
a = Transport()
a.mkdir('a')
b = Transport.clone('a')
a.put('a/foo', 'text')
assert b.get('foo').read() == 'text'

and so on.
John
=:->

>
> Rob
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051018/602e9eff/attachment.pgp 


More information about the bazaar mailing list