[MERGE] Bugfix #85599: ``bzr init`` works with unicode argument LOCATION

Alexander Belchenko bialix at ukr.net
Sun Feb 18 14:13:36 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Arbash Meinel пишет:
> Alexander Belchenko wrote:
>> Fix and test.
> 
> 
> I've also seen similar problems when using the bzr+ssh:// transport,
> since there are some code paths which keep track of the current location
> as a Unicode string, and pass it as a relpath() rather than using the
> url-encoded string.
> 
> One that I've seen is:
> 
> parent, basename = os.path.split(user_path)
> parent_transport = get_transport(parent)
> parent_transport.mkdir(basename)
> 
> It would be better to do this as:
> 
> transport = get_transport(user_path)
> transport.mkdir('.')
> 
> That was a side note, +0.5 on your patch. The main reason I mention it
> is because it is actually BzrDir.create() where the real bug lies.
> Because it is directly passing a Unicode string to t.mkdir().

After reading sources and docstring of BzrDir.create() I come to conclusion
that there is problems with argument type not with unicode itself.

The problem #1: URL and ascii path cannot be easily differentiate.
So check for unicode argument passing to BzrDir.create() is only
halved solution. I think the right fix is to pass transport instead
of URL.

Looking at the code I see this:

    # TODO: Should take a Transport
    @classmethod
    def create(cls, base, format=None):
        """Create a new BzrDir at the url 'base'.

        This will call the current default formats initialize with base
        as the only parameter.

        :param format: If supplied, the format of branch to create.  If not
            supplied, the default is used.
        """

There is already TODO for reworking this method to take transport instead of
URL. And I come to the same conclusion before I read the code.

>
> I'm very happy to see a test for 'bzr init', but I think adding a BzrDir
> test for BzrDir.create() with a unicode path would also be useful.

So I think adding such test for BzrDir.create() is a bit superfluous.
What this test should test actually? Raising of error because of incorrect
argument type? I'm better implement TODO and change argument from URL to
transport -- I think this is *right* way for fixing original problem.

- --
Alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF2F8QzYr338mxwCURApDFAJ9fI4QUBK75obtXF9tAaRhDPJ2ZaQCdEAvE
p6t8a5/SafKSjG/VBSs8FwE=
=SLtT
-----END PGP SIGNATURE-----




More information about the bazaar mailing list