[MERGE] walkdirs sort order
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 16 17:12:03 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Collins wrote:
> On Sat, 2006-06-17 at 01:47 +1000, Robert Collins wrote:
>> On Fri, 2006-06-16 at 10:42 -0500, John Arbash Meinel wrote:
>>
>> ...
>>> Which violates your number prefix.
>>> It only works for 1 layer, not for deeply nested things. (all 1's come
>>> after all 0's, but some 2's occur before the 1's are finished).
>
> Herewith a fix.
>
> +1?
>
> Rob
>
Can you add one more test?
Something that actually does the sort, and makes sure that the resulting
paths are correct. I'm thinking something like:
paths = [
'a',
'a/b',
'a/b/c',
'b',
'b/c',
'd',
'd/e',
'd/e/f',
'd/f',
'd/g',
'g',
]
dir_sorted = [
'a',
'b',
'd',
'g',
'a/b',
'a/b/c',
'b/c',
'd/e',
'd/f',
'd/g',
'd/e/f',
]
paths.sort(key=path_prefix_key)
self.assertEqual(dir_sorted, paths)
I think it is easier to figure out what is going on this way.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEkthTJdeBCYSNAAMRAhhrAKCwnDotlNsxscA6yLtFAYiX7DE3fQCgxTU6
ulh9i/5hLzPQxtuRvxz3ZfY=
=AgDA
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list