Rev 5787: Fix bug #764677. WT.inventory should correctly return TreeReference in http://bazaar.launchpad.net/~jameinel/bzr/2.4-wt-inventory-tree-reference-764677
John Arbash Meinel
john at arbash-meinel.com
Mon Apr 18 18:52:29 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.4-wt-inventory-tree-reference-764677
------------------------------------------------------------
revno: 5787
revision-id: john at arbash-meinel.com-20110418185219-s71kb67ej2pqk3p4
parent: pqm at pqm.ubuntu.com-20110415081233-mqfd5six3sqmi1sn
fixes bug(s): https://launchpad.net/bugs/764677
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-wt-inventory-tree-reference-764677
timestamp: Mon 2011-04-18 20:52:19 +0200
message:
Fix bug #764677. WT.inventory should correctly return TreeReference
for subdirectories which are tree-references when the format supports it.
-------------- next part --------------
=== modified file 'bzrlib/tests/per_tree/test_inv.py'
--- a/bzrlib/tests/per_tree/test_inv.py 2011-04-09 21:00:33 +0000
+++ b/bzrlib/tests/per_tree/test_inv.py 2011-04-18 18:52:19 +0000
@@ -33,41 +33,6 @@
return tree.iter_entries_by_dir([file_id]).next()[1]
-class TestPreviousHeads(per_tree.TestCaseWithTree):
-
- def setUp(self):
- # we want several inventories, that respectively
- # give use the following scenarios:
- # A) fileid not in any inventory (A),
- # B) fileid present in one inventory (B) and (A,B)
- # C) fileid present in two inventories, and they
- # are not mutual descendents (B, C)
- # D) fileid present in two inventories and one is
- # a descendent of the other. (B, D)
- super(TestPreviousHeads, self).setUp()
- self.wt = self.make_branch_and_tree('.')
- self.branch = self.wt.branch
- self.build_tree(['file'])
- self.wt.commit('new branch', allow_pointless=True, rev_id='A')
- self.inv_A = self.branch.repository.get_inventory('A')
- self.wt.add(['file'], ['fileid'])
- self.wt.commit('add file', rev_id='B')
- self.inv_B = self.branch.repository.get_inventory('B')
- uncommit(self.branch, tree=self.wt)
- self.assertEqual(self.branch.revision_history(), ['A'])
- self.wt.commit('another add of file', rev_id='C')
- self.inv_C = self.branch.repository.get_inventory('C')
- self.wt.add_parent_tree_id('B')
- self.wt.commit('merge in B', rev_id='D')
- self.inv_D = self.branch.repository.get_inventory('D')
- self.tree = self.workingtree_to_test_tree(self.wt)
- self.tree.lock_read()
- self.addCleanup(self.tree.unlock)
- self.file_active = get_entry(self.tree, 'fileid')
-
- # TODO: test two inventories with the same file revision
-
-
class TestInventoryWithSymlinks(per_tree.TestCaseWithTree):
_test_needs_features = [tests.SymlinkFeature]
=== modified file 'bzrlib/tests/per_tree/test_path_content_summary.py'
--- a/bzrlib/tests/per_tree/test_path_content_summary.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/per_tree/test_path_content_summary.py 2011-04-18 18:52:19 +0000
@@ -144,10 +144,10 @@
def test_tree_content_summary(self):
tree = self.make_branch_and_tree('tree')
- subtree = self.make_branch_and_tree('tree/path')
- tree.add(['path'])
if not tree.branch.repository._format.supports_tree_reference:
raise tests.TestNotApplicable("Tree references not supported.")
+ subtree = self.make_branch_and_tree('tree/path')
+ tree.add(['path'])
summary = self._convert_tree(tree).path_content_summary('path')
self.assertEqual(4, len(summary))
self.assertEqual('tree-reference', summary[0])
=== 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-18 18:52:19 +0000
@@ -19,7 +19,7 @@
import os
-from bzrlib import inventory
+from bzrlib import inventory, tests
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
@@ -151,3 +151,19 @@
wt.apply_inventory_delta([('', None, root_id, None),
(None, '', 'root-id',
inventory.InventoryDirectory('root-id', '', None))])
+
+
+class TestTreeReference(TestCaseWithWorkingTree):
+
+ def test_tree_reference_matches_inv(self):
+ base = self.make_branch_and_tree('base')
+ subdir = self.make_branch_and_tree('base/subdir')
+ if not base._directory_is_tree_reference('subdir'):
+ raise tests.TestNotApplicable("wt doesn't support nested trees")
+ base.add(['subdir'], ['subdir-id'])
+ self.addCleanup(base.lock_read().unlock)
+ ie = base.inventory['subdir-id']
+ self.assertEqual('tree-reference', ie.kind)
+ path, ie = base.iter_entries_by_dir(['subdir-id']).next()
+ self.assertEqual('subdir', path)
+ self.assertEqual('tree-reference', ie.kind)
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2011-04-09 19:25:42 +0000
+++ b/bzrlib/workingtree_4.py 2011-04-18 18:52:19 +0000
@@ -311,6 +311,9 @@
name_unicode = utf8_decode(name)[0]
file_id = key[2]
kind = minikind_to_kind[minikind]
+ if (name and kind == 'directory'
+ and self._directory_is_tree_reference(name_unicode)):
+ kind = 'tree-reference'
inv_entry = factory[kind](file_id, name_unicode,
parent_ie.file_id)
if kind == 'file':
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-04-14 17:34:17 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-04-18 18:52:19 +0000
@@ -223,6 +223,10 @@
of CHK data, down to just 150MB.) This has noticeable affects for things
like building checkouts, etc. (John Arbash Meinel, #737234)
+* ``WT.inventory`` and ``WT.iter_entries_by_dir()`` was not correctly
+ reporting subdirectories that were tree references (in formats that
+ supported them). (John Arbash Meinel, #764677)
+
Bug Fixes
*********
More information about the bazaar-commits
mailing list