Rev 4561: (igc) Allow rename of items already removed from the inventory in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jul 23 02:25:19 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4561 [merge]
revision-id: pqm at pqm.ubuntu.com-20090723012518-txkanz7di5glol2c
parent: pqm at pqm.ubuntu.com-20090722181834-2geyfaa06s9himqg
parent: ian.clatworthy at canonical.com-20090723002430-70me272jpp3uss7i
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-07-23 02:25:18 +0100
message:
(igc) Allow rename of items already removed from the inventory
(Marius Kruger)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/per_workingtree/test_rename_one.py test_rename_one.py-20070226161242-2d8ibdedl700jgio-1
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'NEWS'
--- a/NEWS 2009-07-22 10:01:36 +0000
+++ b/NEWS 2009-07-23 00:24:30 +0000
@@ -77,6 +77,9 @@
Improvements
************
+* Can now rename/move files even if they have been removed from the inventory.
+ (Marius Kruger)
+
Documentation
*************
=== modified file 'bzrlib/tests/per_workingtree/test_rename_one.py'
--- a/bzrlib/tests/per_workingtree/test_rename_one.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_rename_one.py 2009-07-23 00:24:30 +0000
@@ -220,6 +220,25 @@
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
tree.basis_tree())
+ def test_rename_one_after_source_removed(self):
+ """Rename even if the source was removed from the inventory already"""
+ tree = self.make_branch_and_tree('.')
+ self.build_tree(['a', 'b/'])
+ tree.add(['a', 'b'], ['a-id', 'b-id'])
+ tree.commit('initial', rev_id='rev-1')
+ root_id = tree.get_root_id()
+ os.rename('a', 'b/foo')
+ tree.remove(['a'])
+
+ self.assertTreeLayout([('', root_id), ('b', 'b-id')], tree)
+ # We don't need after=True as long as source is missing and target
+ # exists.
+ tree.rename_one('a', 'b/foo')
+ self.assertTreeLayout([('', root_id), ('b', 'b-id'),
+ ('b/foo', 'a-id')], tree)
+ self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
+ tree.basis_tree())
+
def test_rename_one_after_no_target(self):
tree = self.make_branch_and_tree('.')
self.build_tree(['a', 'b/'])
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2009-07-06 21:13:30 +0000
+++ b/bzrlib/workingtree.py 2009-07-23 00:24:30 +0000
@@ -1476,9 +1476,17 @@
from_tail = splitpath(from_rel)[-1]
from_id = inv.path2id(from_rel)
if from_id is None:
- raise errors.BzrRenameFailedError(from_rel,to_rel,
- errors.NotVersionedError(path=str(from_rel)))
- from_entry = inv[from_id]
+ # if file is missing in the inventory maybe it's in the basis_tree
+ basis_tree = self.branch.basis_tree()
+ from_id = basis_tree.path2id(from_rel)
+ if from_id is None:
+ raise errors.BzrRenameFailedError(from_rel,to_rel,
+ errors.NotVersionedError(path=str(from_rel)))
+ # put entry back in the inventory so we can rename it
+ from_entry = basis_tree.inventory[from_id].copy()
+ inv.add(from_entry)
+ else:
+ from_entry = inv[from_id]
from_parent_id = from_entry.parent_id
to_dir, to_tail = os.path.split(to_rel)
to_dir_id = inv.path2id(to_dir)
More information about the bazaar-commits
mailing list