[MERGE] walkdirs sort order
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 16 18:23:48 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Denys Duchier wrote:
> Robert Collins <robertc at robertcollins.net> writes:
>> As a key, (dirname(path), path) works to pass my tests with an
>> additional test for the case you have exposed.
> by definition of lexicographic order:
> (D1, D1/n1) << (D2, D2/n2) == (D1 < D2) | (D1=D2 & D1/n1<D2/n2)
> by the same definition, we also have:
> (D1, n1) << (D2, n2) == (D1 < D2) | (D1=D2 & n1<n2)
> which is equivalent to the earlier definition. therefore, I suspect your key
> can be simplified to be (dirname(path), basename(path)).
> Am I getting this wrong?
I do believe you are correct. The downside is that it isn't actually
simplified :). The problem being now you have 2 function calls, instead
of just one.
Actually, what would be simpler is to use:
"""Generate a prefix-order path key for path.
This can be used to sort paths in the same way that walkdirs does.
Both dirname() and basename() call 'split()' and then throw away the
other half of the result. So just call it directly. And use the full result.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v126.96.36.199 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar