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
1=== modified file 'NEWS'
2--- NEWS 2009-07-15 19:06:39 +0000
3+++ NEWS 2009-07-15 21:35:30 +0000
4@@ -25,6 +25,10 @@
5 * BranchBuilder now accepts timezone to avoid test failures in countries far
6 from GMT. (Vincent Ladeuil, #397716)
7
8+* ``WorkingTree4.unversion`` will no longer fail to unversion ids which
9+ were present in a parent tree but renamed in the working tree.
10+ (Robert Collins, #187207)
11+
12 Improvements
13 ************
14
15
16=== modified file 'bzrlib/tests/per_workingtree/test_unversion.py'
17--- bzrlib/tests/per_workingtree/test_unversion.py 2009-07-10 07:14:02 +0000
18+++ bzrlib/tests/per_workingtree/test_unversion.py 2009-07-15 21:35:30 +0000
19@@ -37,6 +37,20 @@
20 tree = self.make_branch_and_tree('.')
21 self.assertRaises(errors.NoSuchId, tree.unversion, ['missing-id'])
22
23+ def test_unversion_parent_and_child_renamed_bug_187207(self):
24+ # When unversioning dirstate trees show a bug in dealing with
25+ # unversioning children of reparented children of unversioned
26+ # paths when relocation entries are present and the relocation
27+ # points later into the dirstate.
28+ tree = self.make_branch_and_tree(['.'])
29+ self.build_tree(['del/', 'del/sub/', 'del/sub/b'])
30+ tree.add(['del', 'del/sub', 'del/sub/b'], ['del', 'sub', 'b'])
31+ tree.commit('setup')
32+ tree.rename_one('del/sub', 'sub')
33+ self.assertEqual('sub/b', tree.id2path('b'))
34+ tree.unversion(['del', 'b'])
35+ self.assertRaises(errors.NoSuchId, tree.id2path, 'b')
36+
37 def test_unversion_several_files(self):
38 """After unversioning several files, they should not be versioned."""
39 tree = self.make_branch_and_tree('.')
40
41=== modified file 'bzrlib/workingtree_4.py'
42--- bzrlib/workingtree_4.py 2009-07-06 07:51:29 +0000
43+++ bzrlib/workingtree_4.py 2009-07-15 21:35:30 +0000
44@@ -1195,13 +1195,16 @@
45 # just forget the whole block.
46 entry_index = 0
47 while entry_index < len(block[1]):
48- # Mark this file id as having been removed
49 entry = block[1][entry_index]
50- ids_to_unversion.discard(entry[0][2])
51- if (entry[1][0][0] in 'ar' # don't remove absent or renamed
52- # entries
53- or not state._make_absent(entry)):
54+ if entry[1][0][0] in 'ar':
55+ # don't remove absent or renamed entries
56 entry_index += 1
57+ else:
58+ # Mark this file id as having been removed
59+ ids_to_unversion.discard(entry[0][2])
60+ if not state._make_absent(entry):
61+ # The block has not shrunk.
62+ entry_index += 1
63 # go to the next block. (At the moment we dont delete empty
64 # dirblocks)
65 block_index += 1