[MERGE] Refactor bzrlib.osutils._walkdirs_utf8 to aid API migration in future.

John Arbash Meinel john at arbash-meinel.com
Tue Sep 9 17:19:18 BST 2008


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

Robert Collins wrote:
> This patch refactors the guts of _walkdirs_utf8 to be more modular. 
> 
> In my testing its no slower than trunk (3ms, the expected overhead of a
> call-per-dir on mozilla trees is below noise level). I believe my
> changes to the win32 walker are correct - that is that the win32 feature
> tests will pass and it will run well on win32; I would appreciate a
> win32 developer (two are cc'd to this) confirming that this is the case
> before I submit it to PQM [assuming it gets through review].
> 
> Cheers,
> Rob
> 

I'm attaching a patch which updates the code a bit:

1) You don't have any direct tests for DirReader implementations. This
made it difficult for me to understand what you actually expected
'top_prefix_to_starting_dir' to return. As the only test for the
function was in the win32 walkdirs code, and it was failing.

You actually expect it to return a 5-tuple because you do:

 relroot, _, _, _, top = pending.pop()

but you implemented the Win32DirReader as just returning the 2-tuple
(relroot, top).  I suppose you realized we only need the start and end,
but didn't have another implementation that returned anything but the
5-tuple.

Also, I *think* in your test you swapped the order of 'prefix' and 'top'.

I didn't write any other direct tests, though it would probably be good
to do so at some point.

2) You accidentally used "top + XXX" rather than "top_slash + XXX" on a
few occasions. Which meant we started searching for:

 foo* rather than foo/*

and would return paths as

 fooname rather than foo/name

3) There was a failing test because 'read_dir()' isn't an iterator like
walkdirs_utf8 was, and so an exception was being raised right away,
rather than after a time.


With my update, 'test_osutils.py' and 'test__walkdirs...' pass
successfully on win32.

John
=:->


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

iEYEARECAAYFAkjGogYACgkQJdeBCYSNAAMyUQCgiYUsVTlofSs7mm55xc9qXkSr
3WIAoI9YZfk/gM25yQAAbCMXaLFvoL9k
=pE5Q
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: osutils_readdir_objects.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20080909/dddead65/attachment-0001.diff 


More information about the bazaar mailing list