[MERGE] alias to respect spaces in quoted arguments

Martin Pool mbp at canonical.com
Tue Oct 31 04:55:50 GMT 2006


On 21/10/2006, at 00:45 , Marius Kruger wrote:

> I am happy to make the changes...
> One problem with your suggestion though:
> Note: The shlex module currently does not support Unicode input.
> (http://docs.python.org/dev/lib/module-shlex.html )
> so I don't know if I should use that, as I see that we get the  
> strings as unicode.

It does actually do perversely badly there, because it uses cStringIO:

 >>> shlex.split(u'hello world')
['h\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00',  
'\x00\x00\x00w\x00\x00\x00o\x00\x00\x00r\x00\x00\x00l\x00\x00\x00d\x00 
\x00\x00']

One way to hack around this would be to squash down to utf-8

 >>> [a.decode('utf-8') for a in shlex.split(u'hello world'.encode 
('utf-8'))][u'hello', u'world']

> In regards with the test case, I am also willing...
> but I have not looked at it yet, maybe you could point me in the  
> right direction
> as to where to add it and where to look for setting up  
> configuration data
> for the tests..

The easiest place to add it is in bzrlib/tests/blackbox/ 
test_aliases.  You can split out some of the common setup with the  
existing code and add a new test that creates an alias configuration  
which uses quotes, then makes use of it.

It would actually be better to have a non-blackbox test that only ran  
get_alias directly; you'll need to make sure of how to set up the  
right configuration for the scope of this call which may be slightly  
complicated.  Since we identified the unicode problem we should test  
unicode handling too.

-- 
Martin







More information about the bazaar mailing list