Merge lp:~vila/bzr/533547-dsrt-kind into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~vila/bzr/533547-dsrt-kind
Merge into: lp:bzr
Diff against target: 148 lines (+73/-13)
4 files modified
NEWS (+4/-0)
bzrlib/tests/per_tree/test_revision_tree.py (+9/-6)
bzrlib/tests/per_workingtree/test_revision_tree.py (+57/-6)
bzrlib/workingtree_4.py (+3/-1)
To merge this branch: bzr merge lp:~vila/bzr/533547-dsrt-kind
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+21030@code.launchpad.net

Description of the change

Drive-by fix encountered while working on bug #531967.

That revealed a hole in our test coverage that I won't investigate further than the added test.

The consequences of this bug are unclear as we usually use only the basis tree
(which explain why the bug remained unnoticed).

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/bzr/533547-dsrt-kind into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #533547 OOPS-ID-1526appserver102557
> https://bugs.launchpad.net/bugs/533547
>
>
> Drive-by fix encountered while working on bug #531967.
>
> That revealed a hole in our test coverage that I won't investigate further than the added test.
>
> The consequences of this bug are unclear as we usually use only the basis tree
> (which explain why the bug remained unnoticed).
>

 merge: approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuX4xsACgkQJdeBCYSNAANTmQCeIYKNANyufwbTBcE190hU29L0
DBUAoKrpMCxKCDMcuf6/cBlGnkMnwPif
=fj9/
-----END PGP SIGNATURE-----

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 2010-03-10 06:38:27 +0000
3+++ NEWS 2010-03-10 09:37:14 +0000
4@@ -92,6 +92,10 @@
5 ftp servers while trying to take a lock.
6 (Martin Pool, #528722)
7
8+* DirStateRevisionTree.kind() was returning wrong result when 'kind'
9+ changes occured between the workingtree and one of its parents.
10+ (Vincent Ladeuil, #533437)
11+
12 * Network transfer amounts and rates are now displayed in SI units according
13 to the Ubuntu Units Policy <https://wiki.ubuntu.com/UnitsPolicy>.
14 (Gordon Tyler, #514399)
15
16=== modified file 'bzrlib/tests/per_tree/test_revision_tree.py'
17--- bzrlib/tests/per_tree/test_revision_tree.py 2009-07-10 07:14:02 +0000
18+++ bzrlib/tests/per_tree/test_revision_tree.py 2010-03-10 09:37:14 +0000
19@@ -1,4 +1,4 @@
20-# Copyright (C) 2006 Canonical Ltd
21+# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
22 #
23 # This program is free software; you can redistribute it and/or modify
24 # it under the terms of the GNU General Public License as published by
25@@ -16,11 +16,14 @@
26
27 """Tests for Tree.revision_tree."""
28
29-from bzrlib import errors
30-from bzrlib.tests.per_tree import TestCaseWithTree
31-
32-
33-class TestRevisionTree(TestCaseWithTree):
34+from bzrlib import (
35+ errors,
36+ tests,
37+ )
38+from bzrlib.tests import per_tree
39+
40+
41+class TestRevisionTree(per_tree.TestCaseWithTree):
42
43 def create_tree_no_parents_no_content(self):
44 tree = self.make_branch_and_tree('.')
45
46=== modified file 'bzrlib/tests/per_workingtree/test_revision_tree.py'
47--- bzrlib/tests/per_workingtree/test_revision_tree.py 2009-07-10 07:14:02 +0000
48+++ bzrlib/tests/per_workingtree/test_revision_tree.py 2010-03-10 09:37:14 +0000
49@@ -1,4 +1,4 @@
50-# Copyright (C) 2006 Canonical Ltd
51+# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
52 #
53 # This program is free software; you can redistribute it and/or modify
54 # it under the terms of the GNU General Public License as published by
55@@ -23,11 +23,15 @@
56 so these tests are testing that when there is a cache, it performs correctly.
57 """
58
59-from bzrlib import errors
60-from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
61-
62-
63-class TestRevisionTree(TestCaseWithWorkingTree):
64+from bzrlib import (
65+ branchbuilder,
66+ errors,
67+ tests,
68+ )
69+from bzrlib.tests import per_workingtree
70+
71+
72+class TestRevisionTree(per_workingtree.TestCaseWithWorkingTree):
73
74 def test_get_zeroth_basis_tree_via_revision_tree(self):
75 tree = self.make_branch_and_tree('.')
76@@ -83,3 +87,50 @@
77 return
78 repository_revision_tree = tree.branch.repository.revision_tree(rev1)
79 self.assertTreesEqual(repository_revision_tree, cached_revision_tree)
80+
81+
82+class TestRevisionTreeKind(per_workingtree.TestCaseWithWorkingTree):
83+
84+ def make_branch_with_merged_deletions(self, relpath='tree'):
85+ tree = self.make_branch_and_tree(relpath)
86+ files = ['a', 'b/', 'b/c']
87+ self.build_tree(files, line_endings='binary',
88+ transport=tree.bzrdir.root_transport)
89+ tree.set_root_id('root-id')
90+ tree.add(files, ['a-id', 'b-id', 'c-id'])
91+ tree.commit('a, b and b/c', rev_id='base')
92+ tree2 = tree.bzrdir.sprout(relpath + '2').open_workingtree()
93+ # Delete 'a' in tree
94+ tree.remove('a', keep_files=False)
95+ tree.commit('remove a', rev_id='this')
96+ # Delete 'c' in tree2
97+ tree2.remove('b/c', keep_files=False)
98+ tree2.remove('b', keep_files=False)
99+ tree2.commit('remove b/c', rev_id='other')
100+ # Merge tree2 into tree
101+ tree.merge_from_branch(tree2.branch)
102+ return tree
103+
104+ def test_kind_parent_tree(self):
105+ tree = self.make_branch_with_merged_deletions()
106+ tree.lock_read()
107+ self.addCleanup(tree.unlock)
108+ parents = tree.get_parent_ids()
109+ self.assertEqual(['this', 'other'], parents)
110+ basis = tree.revision_tree(parents[0])
111+ basis.lock_read()
112+ self.addCleanup(basis.unlock)
113+ self.assertRaises(errors.NoSuchId, basis.kind, 'a-id')
114+ self.assertEqual(['directory', 'file'],
115+ [basis.kind('b-id'), basis.kind('c-id')])
116+ try:
117+ other = tree.revision_tree(parents[1])
118+ except errors.NoSuchRevisionInTree:
119+ raise tests.TestNotApplicable(
120+ 'Tree type %s caches only the basis revision tree.'
121+ % type(tree))
122+ other.lock_read()
123+ self.addCleanup(other.unlock)
124+ self.assertRaises(errors.NoSuchId, other.kind, 'b-id')
125+ self.assertRaises(errors.NoSuchId, other.kind, 'c-id')
126+ self.assertEqual('file', other.kind('a-id'))
127
128=== modified file 'bzrlib/workingtree_4.py'
129--- bzrlib/workingtree_4.py 2010-02-17 17:11:16 +0000
130+++ bzrlib/workingtree_4.py 2010-03-10 09:37:14 +0000
131@@ -1372,6 +1372,7 @@
132
133
134 class DirStateWorkingTreeFormat(WorkingTreeFormat3):
135+
136 def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
137 accelerator_tree=None, hardlink=False):
138 """See WorkingTreeFormat.initialize().
139@@ -1832,7 +1833,8 @@
140 entry = self._get_entry(file_id=file_id)[1]
141 if entry is None:
142 raise errors.NoSuchId(tree=self, file_id=file_id)
143- return dirstate.DirState._minikind_to_kind[entry[1][0]]
144+ parent_index = self._get_parent_index()
145+ return dirstate.DirState._minikind_to_kind[entry[parent_index][0]]
146
147 def stored_kind(self, file_id):
148 """See Tree.stored_kind"""