Rev 5821: (jelmer) Skip tests that require an inventory when run against a WorkingTree in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed May 4 16:17:55 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5821 [merge]
revision-id: pqm at pqm.ubuntu.com-20110504161727-0jmxnzxlelp7h8g0
parent: pqm at pqm.ubuntu.com-20110504121051-aovlsmqiivjmc4fc
parent: jelmer at samba.org-20110421203216-r04j4x5vugrup6u9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-05-04 16:17:27 +0000
message:
(jelmer) Skip tests that require an inventory when run against a WorkingTree
that is not inventory based. (Jelmer Vernooij)
modified:
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/per_workingtree/test_add.py test_add.py-20070226165239-4vo178spkrnhavc7-1
bzrlib/tests/per_workingtree/test_add_reference.py test_add_reference.p-20061211024451-yo9i1691dgbv1eyn-1
bzrlib/tests/per_workingtree/test_annotate_iter.py test_annotate_iter.p-20090706211140-0zxeax4auq96gyed-1
bzrlib/tests/per_workingtree/test_basis_inventory.py test_basis_inventory.py-20051218151655-3650468941091309
bzrlib/tests/per_workingtree/test_check.py test_check.py-20090508002343-9659b6salau51zm2-1
bzrlib/tests/per_workingtree/test_executable.py test_executable.py-20060628162557-tr7h57kl80l3ma8i-1
bzrlib/tests/per_workingtree/test_flush.py test_flush.py-20061005073432-585uyj0sua6r7i9v-1
bzrlib/tests/per_workingtree/test_inv.py test_inv.py-20070311221604-ighlq8tbn5xq0kuo-1
bzrlib/tests/per_workingtree/test_parents.py test_set_parents.py-20060807231740-yicmnlci1mj8smu1-1
bzrlib/tests/per_workingtree/test_read_working_inventory.py test_read_working_in-20061005073432-585uyj0sua6r7i9v-2
bzrlib/tests/per_workingtree/test_rename_one.py test_rename_one.py-20070226161242-2d8ibdedl700jgio-1
bzrlib/tests/per_workingtree/test_set_root_id.py test_set_root_id.py-20061004073850-0r1c7qikmnkb8m9k-1
bzrlib/tests/per_workingtree/test_smart_add.py test_smart_add.py-20070215175752-9s5mxoz8aqpd80fm-1
bzrlib/tests/per_workingtree/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
bzrlib/tests/test_commit.py test_commit.py-20050914060732-279f057f8c295434
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2011-04-19 13:59:07 +0000
+++ b/bzrlib/dirstate.py 2011-04-21 20:32:16 +0000
@@ -2474,7 +2474,7 @@
# the suffix is from tree_index+1:parent_count+1.
new_location_suffix = [DirState.NULL_PARENT_DETAILS] * (parent_count - tree_index)
# now stitch in all the entries from this tree
- for path, entry in tree.inventory.iter_entries_by_dir():
+ for path, entry in tree.iter_entries_by_dir():
# here we process each trees details for each item in the tree.
# we first update any existing entries for the id at other paths,
# then we either create or update the entry for the id at the
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2011-04-18 00:44:08 +0000
+++ b/bzrlib/tests/__init__.py 2011-04-21 01:19:32 +0000
@@ -2125,18 +2125,20 @@
% (process_args, retcode, process.returncode))
return [out, err]
- def check_inventory_shape(self, inv, shape):
- """Compare an inventory to a list of expected names.
+ def check_tree_shape(self, tree, shape):
+ """Compare a tree to a list of expected names.
Fail if they are not precisely equal.
"""
extras = []
shape = list(shape) # copy
- for path, ie in inv.entries():
+ for path, ie in tree.iter_entries_by_dir():
name = path.replace('\\', '/')
if ie.kind == 'directory':
name = name + '/'
- if name in shape:
+ if name == "/":
+ pass # ignore root entry
+ elif name in shape:
shape.remove(name)
else:
extras.append(name)
=== modified file 'bzrlib/tests/per_workingtree/test_add.py'
--- a/bzrlib/tests/per_workingtree/test_add.py 2010-11-02 22:12:19 +0000
+++ b/bzrlib/tests/per_workingtree/test_add.py 2011-04-21 20:32:16 +0000
@@ -16,12 +16,9 @@
"""Tests for interface conformance of 'WorkingTree.add'"""
-import os
-
from bzrlib import (
errors,
inventory,
- osutils,
tests,
)
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
=== modified file 'bzrlib/tests/per_workingtree/test_add_reference.py'
--- a/bzrlib/tests/per_workingtree/test_add_reference.py 2011-01-12 18:11:10 +0000
+++ b/bzrlib/tests/per_workingtree/test_add_reference.py 2011-04-21 20:32:16 +0000
@@ -53,8 +53,7 @@
tree.lock_write()
try:
self.assertEqual(tree.path2id('sub-tree'), 'sub-tree-root-id')
- self.assertEqual(tree.inventory['sub-tree-root-id'].kind,
- 'tree-reference')
+ self.assertEqual(tree.kind('sub-tree-root-id'), 'tree-reference')
tree.commit('commit reference')
basis = tree.basis_tree()
basis.lock_read()
=== modified file 'bzrlib/tests/per_workingtree/test_annotate_iter.py'
--- a/bzrlib/tests/per_workingtree/test_annotate_iter.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_annotate_iter.py 2011-04-21 20:32:16 +0000
@@ -16,14 +16,6 @@
"""Tests for interface conformance of 'WorkingTree.annotate_iter'"""
-import os
-
-from bzrlib import (
- errors,
- inventory,
- osutils,
- tests,
- )
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
=== modified file 'bzrlib/tests/per_workingtree/test_basis_inventory.py'
--- a/bzrlib/tests/per_workingtree/test_basis_inventory.py 2009-08-17 06:58:22 +0000
+++ b/bzrlib/tests/per_workingtree/test_basis_inventory.py 2011-04-21 20:32:16 +0000
@@ -14,13 +14,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-import os
-
from bzrlib.tests import TestNotApplicable
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
-from bzrlib.branch import Branch
-from bzrlib import inventory
-from bzrlib.revision import Revision
import bzrlib.xml6
=== modified file 'bzrlib/tests/per_workingtree/test_check.py'
--- a/bzrlib/tests/per_workingtree/test_check.py 2009-08-04 04:47:35 +0000
+++ b/bzrlib/tests/per_workingtree/test_check.py 2011-04-21 20:32:16 +0000
@@ -16,9 +16,6 @@
"""Tests for checking of trees."""
-from bzrlib import (
- tests,
- )
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
=== modified file 'bzrlib/tests/per_workingtree/test_executable.py'
--- a/bzrlib/tests/per_workingtree/test_executable.py 2011-04-14 07:53:38 +0000
+++ b/bzrlib/tests/per_workingtree/test_executable.py 2011-04-21 20:32:16 +0000
@@ -21,7 +21,6 @@
from bzrlib import (
osutils,
)
-from bzrlib.inventory import InventoryFile
from bzrlib.transform import TreeTransform
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
=== modified file 'bzrlib/tests/per_workingtree/test_flush.py'
--- a/bzrlib/tests/per_workingtree/test_flush.py 2009-08-25 23:38:10 +0000
+++ b/bzrlib/tests/per_workingtree/test_flush.py 2011-04-21 20:32:16 +0000
@@ -17,7 +17,7 @@
"""Tests for WorkingTree.flush."""
import sys
-from bzrlib import errors, inventory
+from bzrlib import errors
from bzrlib.tests import TestSkipped
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
=== modified file 'bzrlib/tests/per_workingtree/test_inv.py'
--- a/bzrlib/tests/per_workingtree/test_inv.py 2011-04-09 19:25:42 +0000
+++ b/bzrlib/tests/per_workingtree/test_inv.py 2011-04-21 20:32:16 +0000
@@ -29,14 +29,14 @@
wt = self.make_branch_and_tree('b1')
wt.lock_tree_write()
self.addCleanup(wt.unlock)
- self.assertEqual(len(wt.inventory), 1)
+ self.assertEqual(len(wt.all_file_ids()), 1)
open('b1/a', 'wb').write('a test\n')
wt.add('a')
- self.assertEqual(len(wt.inventory), 2)
+ self.assertEqual(len(wt.all_file_ids()), 2)
wt.flush() # workaround revert doing wt._write_inventory for now.
os.unlink('b1/a')
wt.revert()
- self.assertEqual(len(wt.inventory), 1)
+ self.assertEqual(len(wt.all_file_ids()), 1)
class TestApplyInventoryDelta(TestCaseWithWorkingTree):
=== modified file 'bzrlib/tests/per_workingtree/test_parents.py'
--- a/bzrlib/tests/per_workingtree/test_parents.py 2009-09-09 01:05:31 +0000
+++ b/bzrlib/tests/per_workingtree/test_parents.py 2011-04-21 20:32:16 +0000
@@ -16,14 +16,12 @@
"""Tests of the parent related functions of WorkingTrees."""
-from errno import EEXIST
import os
from bzrlib import (
errors,
osutils,
revision as _mod_revision,
- symbol_versioning,
tests,
)
from bzrlib.inventory import (
=== modified file 'bzrlib/tests/per_workingtree/test_read_working_inventory.py'
--- a/bzrlib/tests/per_workingtree/test_read_working_inventory.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_workingtree/test_read_working_inventory.py 2011-04-21 20:32:16 +0000
@@ -17,19 +17,27 @@
"""Tests for WorkingTree.read_working_inventory."""
from bzrlib import errors, inventory
+from bzrlib.tests import TestNotApplicable
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
+from bzrlib.workingtree import InventoryWorkingTree
class TestReadWorkingInventory(TestCaseWithWorkingTree):
def test_trivial_read(self):
tree = self.make_branch_and_tree('t1')
+ if not isinstance(tree, InventoryWorkingTree):
+ raise TestNotApplicable("read_working_inventory not usable on "
+ "non-inventory working trees")
tree.lock_read()
self.assertIsInstance(tree.read_working_inventory(), inventory.Inventory)
tree.unlock()
def test_read_after_inventory_modification(self):
tree = self.make_branch_and_tree('tree')
+ if not isinstance(tree, InventoryWorkingTree):
+ raise TestNotApplicable("read_working_inventory not usable on "
+ "non-inventory working trees")
# prepare for a series of changes that will modify the
# inventory
tree.lock_write()
=== modified file 'bzrlib/tests/per_workingtree/test_rename_one.py'
--- a/bzrlib/tests/per_workingtree/test_rename_one.py 2011-04-15 07:01:22 +0000
+++ b/bzrlib/tests/per_workingtree/test_rename_one.py 2011-04-21 20:32:16 +0000
@@ -221,7 +221,7 @@
tree.basis_tree())
def test_rename_one_after_source_removed(self):
- """Rename even if the source was removed from the inventory already"""
+ """Rename even if the source was already unversioned."""
tree = self.make_branch_and_tree('.')
self.build_tree(['a', 'b/'])
tree.add(['a', 'b'], ['a-id', 'b-id'])
=== modified file 'bzrlib/tests/per_workingtree/test_set_root_id.py'
--- a/bzrlib/tests/per_workingtree/test_set_root_id.py 2010-01-13 23:06:42 +0000
+++ b/bzrlib/tests/per_workingtree/test_set_root_id.py 2011-04-21 20:32:16 +0000
@@ -18,7 +18,7 @@
import sys
-from bzrlib import errors, inventory
+from bzrlib import errors
from bzrlib.tests import TestSkipped
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
=== modified file 'bzrlib/tests/per_workingtree/test_smart_add.py'
--- a/bzrlib/tests/per_workingtree/test_smart_add.py 2011-02-24 16:45:27 +0000
+++ b/bzrlib/tests/per_workingtree/test_smart_add.py 2011-04-21 20:32:16 +0000
@@ -252,10 +252,10 @@
self.addCleanup(wt.unlock)
self.assertEqual([('', wt.path2id('')),
('dir1', 'directory-dir1'),
+ ('file1', 'file-file1'),
('dir1/file2', 'file-dir1%file2'),
- ('file1', 'file-file1'),
], [(path, ie.file_id) for path, ie
- in wt.inventory.iter_entries()])
+ in wt.iter_entries_by_dir()])
class TestSmartAddConflictRelatedFiles(per_workingtree.TestCaseWithWorkingTree):
@@ -311,7 +311,7 @@
self.addCleanup(self.wt.unlock)
self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
[(path, ie.kind) for path,ie in
- self.wt.inventory.iter_entries()])
+ self.wt.iter_entries_by_dir()])
def test_accessible_implicit(self):
osutils.normalized_filename = osutils._accessible_normalized_filename
@@ -326,7 +326,7 @@
self.addCleanup(self.wt.unlock)
self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
[(path, ie.kind) for path,ie
- in self.wt.inventory.iter_entries()])
+ in self.wt.iter_entries_by_dir()])
def test_inaccessible_explicit(self):
osutils.normalized_filename = osutils._inaccessible_normalized_filename
=== modified file 'bzrlib/tests/per_workingtree/test_workingtree.py'
--- a/bzrlib/tests/per_workingtree/test_workingtree.py 2011-04-20 16:40:53 +0000
+++ b/bzrlib/tests/per_workingtree/test_workingtree.py 2011-04-21 20:32:16 +0000
@@ -41,6 +41,7 @@
TreeDirectory,
TreeFile,
TreeLink,
+ InventoryWorkingTree,
WorkingTree,
)
from bzrlib.conflicts import ConflictList, TextConflict, ContentsConflict
@@ -244,21 +245,19 @@
revid = b.revision_history()[0]
self.log('first revision_id is {%s}' % revid)
- inv = b.repository.get_inventory(revid)
- self.log('contents of inventory: %r' % inv.entries())
+ tree = b.repository.revision_tree(revid)
+ self.log('contents of tree: %r' % list(tree.iter_entries_by_dir()))
- self.check_inventory_shape(inv,
- ['dir/', 'dir/sub/', 'dir/sub/file'])
+ self.check_tree_shape(tree, ['dir/', 'dir/sub/', 'dir/sub/file'])
wt.rename_one('dir', 'newdir')
wt.lock_read()
- self.check_inventory_shape(wt.inventory,
+ self.check_tree_shape(wt,
['newdir/', 'newdir/sub/', 'newdir/sub/file'])
wt.unlock()
wt.rename_one('newdir/sub', 'newdir/newsub')
wt.lock_read()
- self.check_inventory_shape(wt.inventory,
- ['newdir/', 'newdir/newsub/',
+ self.check_tree_shape(wt, ['newdir/', 'newdir/newsub/',
'newdir/newsub/file'])
wt.unlock()
@@ -775,7 +774,7 @@
tree.lock_read()
self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
[(path, ie.kind) for path,ie in
- tree.inventory.iter_entries()])
+ tree.iter_entries_by_dir()])
tree.unlock()
finally:
osutils.normalized_filename = orig
@@ -797,6 +796,9 @@
def test__write_inventory(self):
# The private interface _write_inventory is currently used by transform.
tree = self.make_branch_and_tree('.')
+ if not isinstance(tree, InventoryWorkingTree):
+ raise TestNotApplicable("_write_inventory does not exist on "
+ "non-inventory working trees")
# if we write write an inventory then do a walkdirs we should get back
# missing entries, and actual, and unknowns as appropriate.
self.build_tree(['present', 'unknown'])
=== modified file 'bzrlib/tests/test_commit.py'
--- a/bzrlib/tests/test_commit.py 2011-04-16 08:42:21 +0000
+++ b/bzrlib/tests/test_commit.py 2011-04-20 16:26:15 +0000
@@ -262,18 +262,16 @@
eq(tree1.id2path('hello-id'), 'hello')
eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
self.assertFalse(tree1.has_filename('fruity'))
- self.check_inventory_shape(tree1.inventory, ['hello'])
- ie = tree1.inventory['hello-id']
- eq(ie.revision, 'test at rev-1')
+ self.check_tree_shape(tree1, ['hello'])
+ eq(tree1.get_file_revision('hello-id'), 'test at rev-1')
tree2 = b.repository.revision_tree('test at rev-2')
tree2.lock_read()
self.addCleanup(tree2.unlock)
eq(tree2.id2path('hello-id'), 'fruity')
eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
- self.check_inventory_shape(tree2.inventory, ['fruity'])
- ie = tree2.inventory['hello-id']
- eq(ie.revision, 'test at rev-2')
+ self.check_tree_shape(tree2, ['fruity'])
+ eq(tree2.get_file_revision('hello-id'), 'test at rev-2')
def test_reused_rev_id(self):
"""Test that a revision id cannot be reused in a branch"""
@@ -300,8 +298,7 @@
wt.commit('two', rev_id=r2, allow_pointless=False)
wt.lock_read()
try:
- self.check_inventory_shape(wt.read_working_inventory(),
- ['a/', 'a/hello', 'b/'])
+ self.check_tree_shape(wt, ['a/', 'a/hello', 'b/'])
finally:
wt.unlock()
@@ -310,9 +307,9 @@
wt.commit('three', rev_id=r3, allow_pointless=False)
wt.lock_read()
try:
- self.check_inventory_shape(wt.read_working_inventory(),
+ self.check_tree_shape(wt,
['a/', 'a/hello', 'a/b/'])
- self.check_inventory_shape(b.repository.get_inventory(r3),
+ self.check_tree_shape(b.repository.revision_tree(r3),
['a/', 'a/hello', 'a/b/'])
finally:
wt.unlock()
@@ -322,8 +319,7 @@
wt.commit('four', rev_id=r4, allow_pointless=False)
wt.lock_read()
try:
- self.check_inventory_shape(wt.read_working_inventory(),
- ['a/', 'a/b/hello', 'a/b/'])
+ self.check_tree_shape(wt, ['a/', 'a/b/hello', 'a/b/'])
finally:
wt.unlock()
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2011-05-04 01:42:10 +0000
+++ b/bzrlib/tests/test_selftest.py 2011-05-04 16:17:27 +0000
@@ -2812,16 +2812,16 @@
self.assertEqual(remaining_names, _test_ids(split_suite[1]))
-class TestCheckInventoryShape(tests.TestCaseWithTransport):
+class TestCheckTreeShape(tests.TestCaseWithTransport):
- def test_check_inventory_shape(self):
+ def test_check_tree_shape(self):
files = ['a', 'b/', 'b/c']
tree = self.make_branch_and_tree('.')
self.build_tree(files)
tree.add(files)
tree.lock_read()
try:
- self.check_inventory_shape(tree.inventory, files)
+ self.check_tree_shape(tree, files)
finally:
tree.unlock()
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2011-05-04 08:49:15 +0000
+++ b/bzrlib/workingtree.py 2011-05-04 16:17:27 +0000
@@ -753,36 +753,6 @@
self._set_merges_from_parent_ids(revision_ids)
@needs_tree_write_lock
- def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
- """See MutableTree.set_parent_trees."""
- parent_ids = [rev for (rev, tree) in parents_list]
- for revision_id in parent_ids:
- _mod_revision.check_not_reserved_id(revision_id)
-
- self._check_parents_for_ghosts(parent_ids,
- allow_leftmost_as_ghost=allow_leftmost_as_ghost)
-
- parent_ids = self._filter_parent_ids_by_ancestry(parent_ids)
-
- if len(parent_ids) == 0:
- leftmost_parent_id = _mod_revision.NULL_REVISION
- leftmost_parent_tree = None
- else:
- leftmost_parent_id, leftmost_parent_tree = parents_list[0]
-
- if self._change_last_revision(leftmost_parent_id):
- if leftmost_parent_tree is None:
- # If we don't have a tree, fall back to reading the
- # parent tree from the repository.
- self._cache_basis_inventory(leftmost_parent_id)
- else:
- inv = leftmost_parent_tree.inventory
- xml = self._create_basis_xml_from_inventory(
- leftmost_parent_id, inv)
- self._write_basis_inventory(xml)
- self._set_merges_from_parent_ids(parent_ids)
-
- @needs_tree_write_lock
def set_pending_merges(self, rev_list):
parents = self.get_parent_ids()
leftmost = parents[:1]
@@ -1980,6 +1950,36 @@
"""See Tree.iter_all_file_ids"""
return set(self.inventory)
+ @needs_tree_write_lock
+ def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
+ """See MutableTree.set_parent_trees."""
+ parent_ids = [rev for (rev, tree) in parents_list]
+ for revision_id in parent_ids:
+ _mod_revision.check_not_reserved_id(revision_id)
+
+ self._check_parents_for_ghosts(parent_ids,
+ allow_leftmost_as_ghost=allow_leftmost_as_ghost)
+
+ parent_ids = self._filter_parent_ids_by_ancestry(parent_ids)
+
+ if len(parent_ids) == 0:
+ leftmost_parent_id = _mod_revision.NULL_REVISION
+ leftmost_parent_tree = None
+ else:
+ leftmost_parent_id, leftmost_parent_tree = parents_list[0]
+
+ if self._change_last_revision(leftmost_parent_id):
+ if leftmost_parent_tree is None:
+ # If we don't have a tree, fall back to reading the
+ # parent tree from the repository.
+ self._cache_basis_inventory(leftmost_parent_id)
+ else:
+ inv = leftmost_parent_tree.inventory
+ xml = self._create_basis_xml_from_inventory(
+ leftmost_parent_id, inv)
+ self._write_basis_inventory(xml)
+ self._set_merges_from_parent_ids(parent_ids)
+
def _cache_basis_inventory(self, new_revision):
"""Cache new_revision as the basis inventory."""
# TODO: this should allow the ready-to-use inventory to be passed in,
More information about the bazaar-commits
mailing list