[BUG] transport/memory.py doesn't handle strings
Robert Collins
robertc at robertcollins.net
Wed Oct 19 03:53:36 BST 2005
On Tue, 2005-10-18 at 20:39 -0400, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Robert Collins wrote:
> > On Tue, 2005-10-18 at 16:45 -0500, John A Meinel wrote:
> >
> >>There are a couple of changes that should be made to the
> >>transport/memory.py implementation.
> >>First, most of the "put" functions can take either a file-like object, or
> >>a string. Which means that MemoryTransport.put() shouldn't just call
> >>read(), it should also check to see if it is already a string. (Either
> >>that, or we can change the api if you really prefer).
> >
> >
> > I think that the ambigious api is very strange. I'd much rather have
> > explict put_stream, put_string etc.
>
> I'd rather have put_iterable, because files are iterables of strings,
> but so are lists, and so are strings. So all of these have the same result:
>
> put_iterable('hello')
> put_iterable(['hel','lo'])
> put_iterable(StringIO('hello'))
>
> I can always adapt an interable into a file, but why bother when we only
> need an iterator of strings in the first place?
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.
> >>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 ?
Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051019/83a3e318/attachment.pgp
More information about the bazaar
mailing list