[patch][win32] Use u'.' not '.' as hardcoded path

John Arbash Meinel john at arbash-meinel.com
Mon Jan 2 21:29:40 GMT 2006


Robert Collins wrote:
> On Mon, 2005-12-26 at 16:08 -0600, John A Meinel wrote:
> 
> 
>>Actually, I think we just need to change either the Branch api, or the
>>Transport one, so that any string that comes in gets converted into a
>>unicode string.
>>
>>So we do something like this:
>>
>>class BzrBranch...
>>
>>  def initialize(path):
>>    path = unicode(path)
>>    t = get_transport(path)
>>
>>Though really I think it would probably be best to do this in Transport.
>> I'm guessing that http and sftp may need to deal differently with
>>unicode strings, since they will tend to be url encoded, not strait strings.
> 
> 
> Transport -only- deals with ascii strings - because it deals with URLs
> (which are all ascii). This makes Transport relatively simple as we can
> define the decoding charset ourselves (url consumers are the producers
> and get to say such things).
> 

Well, that means that we need to do some encoding in other places. Since
there are places that do the equivalent of:

for fname in os.listdir(foo):
  f = transport.get(fname)

The reason we need to pass unicode strings to branch constructors is
because Windows requires using the unicode api to handle non-ascii
filenames.


> 
> 
>>So LocalTransport should do something like:
>>    def __init__(self, base):
>>        """Set the base path where files will be stored."""
>>        if base.startswith('file://'):
>>            base = base[7:]
>>        base = unicode(base)
> 
> 
> base = base.decode('utf8')
> 
> :)
> 
> Rob

Isn't it:
base = urldecode(base).decode('utf-8')

Because some of the characters would be escaped into %2F or whatever.

It also means that 'LocalTransport.list_dir()' needs to encode the
filenames. If you are truly intending that the Transport api is always urls.

It seems a little foolish to do utf8 + url encoding in
Transport.list_dir(), and then do utf8 + url decoding in get(), but I
suppose it makes it consistent, and probably doesn't add a lot of overhead.

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060102/c9d7d650/attachment.pgp 


More information about the bazaar mailing list