[MERGE][bug 105479] Move children of a directory correctly

John Arbash Meinel john at arbash-meinel.com
Fri Apr 20 21:42:05 BST 2007

I was investigating bug 105479, and I managed to distill it down into a
few specific bugs, all relating to improperly handling children when
renaming a directory.

The cases were:

1) newly added child, when moving this child, it is removed from the
current directory block, causing our "for entry in block" to skip over
the next entry.

2) deleted child, we would try to _make_absent() an entry which was
already deleted. There is nothing that needs to be done for this case.

3) renamed out child. If you had "a/b", and you renamed "a/b => b", and
then later moved "a => c/a". We would try to update the "a/b" record,
but we don't need to, because "b" isn't there anymore.

The fix is actually pretty simple

1) Use "for entry in block[:]" to not iterate over a list which is changing

2) skip "a" or "r" records. They will be taken care of (if they have to)
when we get to the real entry.

3) Add a _validate() test that we don't have orphaned entries.
(non-absent entries in absent directories)

4) Add a bunch of tests, some of which used to fail, others just handle
more edge cases.

These are probably good edge cases to include in _iter_changes tests.
But for now, I was just focusing on getting "Tree.move()" correct.

This is also probably worthy of backporting to 0.15.1, since it is a
regression. I've tried to mark backport-worthy bugs as such.


PS> These should also probably be added to "Tree.rename_one()" tests,
but currently that still uses the Inventory based renaming.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rename_directory_105479.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070420/c132ad84/attachment-0001.diff 

More information about the bazaar mailing list