On Windows 7, a "bzr checkout" command failed with this error, though a later one succeeded.
159.151 Traceback (most recent call last):
File "bzrlib\commands.pyo", line 853, in exception_to_return_code
File "bzrlib\commands.pyo", line 1055, in run_bzr
File "bzrlib\commands.pyo", line 661, in run_argv_aliases
File "bzrlib\commands.pyo", line 665, in run_direct
File "bzrlib\cleanup.pyo", line 122, in run_simple
File "bzrlib\cleanup.pyo", line 156, in _do_with_cleanups
File "bzrlib\builtins.pyo", line 1328, in run
File "C:/Program Files (x86)/Bazaar/plugins\svn\branch.py", line 337, in create_checkout
File "C:/Program Files (x86)/Bazaar/plugins\svn\branch.py", line 283, in _create_heavyweight_checkout
File "bzrlib\bzrdir.pyo", line 1616, in create_workingtree
File "bzrlib\workingtree_4.pyo", line 1462, in initialize
File "bzrlib\transform.pyo", line 2253, in build_tree
File "bzrlib\transform.pyo", line 2365, in _build_tree
File "bzrlib\transform.pyo", line 1103, in finalize
File "bzrlib\osutils.pyo", line 1038, in delete_any
File "bzrlib\osutils.pyo", line 1058, in _delete_file_or_dir
WindowsError: [Error 145] The directory is not empty: u'C:/Users/exarkun/twistedbot/windows7-64-py2.6-select/Twisted/.bzr/checkout/limbo/new-7/words'
This seems to be from the delete_any call in DiskTreeTransform that isn't wrapped in a try/finally.
I wonder if it would be acceptable to catch the OSError and just emit a warning rather than fail in this situation?
I also wonder about the correctness of this code on a case-insensitive filesystem:
entries = [(self. _limbo_ name(t) , t, k) for t, k in self._new_ contents. iteritems( )]
entries. sort(reverse= True)
for path, trans_id, kind in entries: delete_any(path)
(formatting tweaked to avoid LP munging it too badly)
Probably it's ok to assume that the various entries will be returned with consistent case... but if it's not a safe assumption then this code might try to delete 'a' before 'A/B'. [I suppose an other Windows-specific issue is that path separator is \ on Windows, but A\B and A/B should both before A after a sort(reverse= True).]
It might be good to catch OSError around that delete_any, and try to report more details about the failing path if it does happen, e.g. perms, contents if a dir, etc.