Merge lp:~lifeless/bzr/bug-187207 into lp:~bzr/bzr/trunk-old

Proposed by Robert Collins
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~lifeless/bzr/bug-187207
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 65 lines
To merge this branch: bzr merge lp:~lifeless/bzr/bug-187207
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+8800@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Fix WorkingTree4.unversion when unversioning the parents of files that
were renamed from a basis tree. (Robert Collins, bug 187207)

This fixes a somewhat obscure cause of commit failures. No actual
corruption or higher level bugs were caused, but it was a definite bug.

-Rob

Revision history for this message
John A Meinel (jameinel) wrote :

seems good enough.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-07-15 19:06:39 +0000
+++ NEWS 2009-07-15 21:35:30 +0000
@@ -25,6 +25,10 @@
25* BranchBuilder now accepts timezone to avoid test failures in countries far25* BranchBuilder now accepts timezone to avoid test failures in countries far
26 from GMT. (Vincent Ladeuil, #397716)26 from GMT. (Vincent Ladeuil, #397716)
2727
28* ``WorkingTree4.unversion`` will no longer fail to unversion ids which
29 were present in a parent tree but renamed in the working tree.
30 (Robert Collins, #187207)
31
28Improvements32Improvements
29************33************
3034
3135
=== modified file 'bzrlib/tests/per_workingtree/test_unversion.py'
--- bzrlib/tests/per_workingtree/test_unversion.py 2009-07-10 07:14:02 +0000
+++ bzrlib/tests/per_workingtree/test_unversion.py 2009-07-15 21:35:30 +0000
@@ -37,6 +37,20 @@
37 tree = self.make_branch_and_tree('.')37 tree = self.make_branch_and_tree('.')
38 self.assertRaises(errors.NoSuchId, tree.unversion, ['missing-id'])38 self.assertRaises(errors.NoSuchId, tree.unversion, ['missing-id'])
3939
40 def test_unversion_parent_and_child_renamed_bug_187207(self):
41 # When unversioning dirstate trees show a bug in dealing with
42 # unversioning children of reparented children of unversioned
43 # paths when relocation entries are present and the relocation
44 # points later into the dirstate.
45 tree = self.make_branch_and_tree(['.'])
46 self.build_tree(['del/', 'del/sub/', 'del/sub/b'])
47 tree.add(['del', 'del/sub', 'del/sub/b'], ['del', 'sub', 'b'])
48 tree.commit('setup')
49 tree.rename_one('del/sub', 'sub')
50 self.assertEqual('sub/b', tree.id2path('b'))
51 tree.unversion(['del', 'b'])
52 self.assertRaises(errors.NoSuchId, tree.id2path, 'b')
53
40 def test_unversion_several_files(self):54 def test_unversion_several_files(self):
41 """After unversioning several files, they should not be versioned."""55 """After unversioning several files, they should not be versioned."""
42 tree = self.make_branch_and_tree('.')56 tree = self.make_branch_and_tree('.')
4357
=== modified file 'bzrlib/workingtree_4.py'
--- bzrlib/workingtree_4.py 2009-07-06 07:51:29 +0000
+++ bzrlib/workingtree_4.py 2009-07-15 21:35:30 +0000
@@ -1195,13 +1195,16 @@
1195 # just forget the whole block.1195 # just forget the whole block.
1196 entry_index = 01196 entry_index = 0
1197 while entry_index < len(block[1]):1197 while entry_index < len(block[1]):
1198 # Mark this file id as having been removed
1199 entry = block[1][entry_index]1198 entry = block[1][entry_index]
1200 ids_to_unversion.discard(entry[0][2])1199 if entry[1][0][0] in 'ar':
1201 if (entry[1][0][0] in 'ar' # don't remove absent or renamed1200 # don't remove absent or renamed entries
1202 # entries
1203 or not state._make_absent(entry)):
1204 entry_index += 11201 entry_index += 1
1202 else:
1203 # Mark this file id as having been removed
1204 ids_to_unversion.discard(entry[0][2])
1205 if not state._make_absent(entry):
1206 # The block has not shrunk.
1207 entry_index += 1
1205 # go to the next block. (At the moment we dont delete empty1208 # go to the next block. (At the moment we dont delete empty
1206 # dirblocks)1209 # dirblocks)
1207 block_index += 11210 block_index += 1