Rev 5600: Move away from using Tree.inventory[] just to check if this is a root. in http://bazaar.launchpad.net/~jameinel/bzr/2.3-unshelve-inventory-bug-389674
John Arbash Meinel
john at arbash-meinel.com
Wed Jan 12 18:25:08 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.3-unshelve-inventory-bug-389674
------------------------------------------------------------
revno: 5600
revision-id: john at arbash-meinel.com-20110112182501-1ssvktrps03etyo0
parent: pqm at pqm.ubuntu.com-20110112172132-p7n9cxhslpn6svhh
fixes bug(s): https://launchpad.net/bugs/389674
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-unshelve-inventory-bug-389674
timestamp: Wed 2011-01-12 12:25:01 -0600
message:
Move away from using Tree.inventory[] just to check if this is a root.
Fixes bug #389674 because PreviewTree doesn't have an inventory attribute.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_shelf.py'
--- a/bzrlib/tests/test_shelf.py 2010-09-17 15:15:34 +0000
+++ b/bzrlib/tests/test_shelf.py 2011-01-12 18:25:01 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, 2009, 2010 Canonical Ltd
+# Copyright (C) 2008-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -623,6 +623,29 @@
shelf_file)
self.assertEqual('Shelf corrupt.', str(e))
+ def test_unshelve_subdir_in_now_removed_dir(self):
+ tree = self.make_branch_and_tree('.')
+ self.addCleanup(tree.lock_write().unlock)
+ self.build_tree(['dir/', 'dir/subdir/', 'dir/subdir/foo'])
+ tree.add(['dir'], ['dir-id'])
+ tree.commit('versioned dir')
+ tree.add(['dir/subdir', 'dir/subdir/foo'], ['subdir-id', 'foo-id'])
+ creator = shelf.ShelfCreator(tree, tree.basis_tree())
+ self.addCleanup(creator.finalize)
+ for change in creator.iter_shelvable():
+ creator.shelve_change(change)
+ shelf_manager = tree.get_shelf_manager()
+ shelf_id = shelf_manager.shelve_changes(creator)
+ self.failIfExists('dir/subdir')
+ tree.remove(['dir'])
+ unshelver = shelf_manager.get_unshelver(shelf_id)
+ self.addCleanup(unshelver.finalize)
+ unshelver.make_merger().do_merge()
+ self.failUnlessExists('dir/subdir/foo')
+ self.assertEqual('dir-id', tree.path2id('dir'))
+ self.assertEqual('subdir-id', tree.path2id('dir/subdir'))
+ self.assertEqual('foo-id', tree.path2id('dir/subdir/foo'))
+
class TestShelfManager(tests.TestCaseWithTransport):
=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py 2011-01-12 01:01:53 +0000
+++ b/bzrlib/transform.py 2011-01-12 18:25:01 +0000
@@ -528,6 +528,8 @@
for trans_id in self._removed_id:
file_id = self.tree_file_id(trans_id)
if file_id is not None:
+ # XXX: This seems like something that should go via a different
+ # indirection.
if self._tree.inventory[file_id].kind == 'directory':
parents.append(trans_id)
elif self.tree_kind(trans_id) == 'directory':
@@ -3020,7 +3022,8 @@
file_id = tt.inactive_file_id(conflict[1])
# special-case the other tree root (move its children instead)
if path_tree and file_id in path_tree:
- if path_tree.inventory[file_id].parent_id is None:
+ if path_tree.path2id('') == file_id:
+ # This is the root entry, skip it
continue
tt.version_file(file_id, conflict[1])
new_conflicts.add((c_type, 'Versioned directory', conflict[1]))
More information about the bazaar-commits
mailing list