Rev 5083: (vila) DirStateRevisionTree.kind() now respect parent_index in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Mar 11 09:13:25 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5083 [merge]
revision-id: pqm at pqm.ubuntu.com-20100311091324-65tj2auj54teihjn
parent: pqm at pqm.ubuntu.com-20100311053854-0aw575c1892k1djg
parent: v.ladeuil+lp at free.fr-20100311084128-nvkfsllql4ojywbg
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-03-11 09:13:24 +0000
message:
(vila) DirStateRevisionTree.kind() now respect parent_index
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/per_tree/test_revision_tree.py test_revision_tree.p-20060908041847-n15ngjoxpivwls0v-1
bzrlib/tests/per_workingtree/test_revision_tree.py test_revision_tree.p-20060908041847-n15ngjoxpivwls0v-2
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'NEWS'
--- a/NEWS 2010-03-11 05:38:54 +0000
+++ b/NEWS 2010-03-11 08:41:28 +0000
@@ -96,6 +96,10 @@
ftp servers while trying to take a lock.
(Martin Pool, #528722)
+* DirStateRevisionTree.kind() was returning wrong result when 'kind'
+ changes occured between the workingtree and one of its parents.
+ (Vincent Ladeuil, #533437)
+
* Fix stub sftp test server to call os.getcwdu().
(Vincent Ladeuil, #526211, #526353)
=== modified file 'bzrlib/tests/per_tree/test_revision_tree.py'
--- a/bzrlib/tests/per_tree/test_revision_tree.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_tree/test_revision_tree.py 2010-03-10 09:26:51 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006, 2007, 2009, 2010 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
@@ -16,11 +16,14 @@
"""Tests for Tree.revision_tree."""
-from bzrlib import errors
-from bzrlib.tests.per_tree import TestCaseWithTree
-
-
-class TestRevisionTree(TestCaseWithTree):
+from bzrlib import (
+ errors,
+ tests,
+ )
+from bzrlib.tests import per_tree
+
+
+class TestRevisionTree(per_tree.TestCaseWithTree):
def create_tree_no_parents_no_content(self):
tree = self.make_branch_and_tree('.')
=== modified file 'bzrlib/tests/per_workingtree/test_revision_tree.py'
--- a/bzrlib/tests/per_workingtree/test_revision_tree.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_revision_tree.py 2010-03-10 09:33:04 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006, 2007, 2009, 2010 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
@@ -23,11 +23,15 @@
so these tests are testing that when there is a cache, it performs correctly.
"""
-from bzrlib import errors
-from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
-
-
-class TestRevisionTree(TestCaseWithWorkingTree):
+from bzrlib import (
+ branchbuilder,
+ errors,
+ tests,
+ )
+from bzrlib.tests import per_workingtree
+
+
+class TestRevisionTree(per_workingtree.TestCaseWithWorkingTree):
def test_get_zeroth_basis_tree_via_revision_tree(self):
tree = self.make_branch_and_tree('.')
@@ -83,3 +87,50 @@
return
repository_revision_tree = tree.branch.repository.revision_tree(rev1)
self.assertTreesEqual(repository_revision_tree, cached_revision_tree)
+
+
+class TestRevisionTreeKind(per_workingtree.TestCaseWithWorkingTree):
+
+ def make_branch_with_merged_deletions(self, relpath='tree'):
+ tree = self.make_branch_and_tree(relpath)
+ files = ['a', 'b/', 'b/c']
+ self.build_tree(files, line_endings='binary',
+ transport=tree.bzrdir.root_transport)
+ tree.set_root_id('root-id')
+ tree.add(files, ['a-id', 'b-id', 'c-id'])
+ tree.commit('a, b and b/c', rev_id='base')
+ tree2 = tree.bzrdir.sprout(relpath + '2').open_workingtree()
+ # Delete 'a' in tree
+ tree.remove('a', keep_files=False)
+ tree.commit('remove a', rev_id='this')
+ # Delete 'c' in tree2
+ tree2.remove('b/c', keep_files=False)
+ tree2.remove('b', keep_files=False)
+ tree2.commit('remove b/c', rev_id='other')
+ # Merge tree2 into tree
+ tree.merge_from_branch(tree2.branch)
+ return tree
+
+ def test_kind_parent_tree(self):
+ tree = self.make_branch_with_merged_deletions()
+ tree.lock_read()
+ self.addCleanup(tree.unlock)
+ parents = tree.get_parent_ids()
+ self.assertEqual(['this', 'other'], parents)
+ basis = tree.revision_tree(parents[0])
+ basis.lock_read()
+ self.addCleanup(basis.unlock)
+ self.assertRaises(errors.NoSuchId, basis.kind, 'a-id')
+ self.assertEqual(['directory', 'file'],
+ [basis.kind('b-id'), basis.kind('c-id')])
+ try:
+ other = tree.revision_tree(parents[1])
+ except errors.NoSuchRevisionInTree:
+ raise tests.TestNotApplicable(
+ 'Tree type %s caches only the basis revision tree.'
+ % type(tree))
+ other.lock_read()
+ self.addCleanup(other.unlock)
+ self.assertRaises(errors.NoSuchId, other.kind, 'b-id')
+ self.assertRaises(errors.NoSuchId, other.kind, 'c-id')
+ self.assertEqual('file', other.kind('a-id'))
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/workingtree_4.py 2010-03-10 09:31:25 +0000
@@ -1372,6 +1372,7 @@
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
+
def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
accelerator_tree=None, hardlink=False):
"""See WorkingTreeFormat.initialize().
@@ -1832,7 +1833,8 @@
entry = self._get_entry(file_id=file_id)[1]
if entry is None:
raise errors.NoSuchId(tree=self, file_id=file_id)
- return dirstate.DirState._minikind_to_kind[entry[1][0]]
+ parent_index = self._get_parent_index()
+ return dirstate.DirState._minikind_to_kind[entry[parent_index][0]]
def stored_kind(self, file_id):
"""See Tree.stored_kind"""
More information about the bazaar-commits
mailing list