Rev 4672: (broken) Start working on actually writing a permutation for per_inventory. in http://bazaar.launchpad.net/~jameinel/bzr/2.0.1-faster-log-dir-bug374730
John Arbash Meinel
john at arbash-meinel.com
Wed Sep 23 23:14:48 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.0.1-faster-log-dir-bug374730
------------------------------------------------------------
revno: 4672
revision-id: john at arbash-meinel.com-20090923221434-nxjx0is3chbh37do
parent: john at arbash-meinel.com-20090923220537-eflh2f38dfflxvix
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0.1-faster-log-dir-bug374730
timestamp: Wed 2009-09-23 17:14:34 -0500
message:
(broken) Start working on actually writing a permutation for per_inventory.
For now, we'll do something similar to the per-tree code. Where we create a regular
Inventory object to do mutation, and then snapshot it into a final representation for testing.
-------------- next part --------------
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py 2009-09-23 22:05:37 +0000
+++ b/bzrlib/inventory.py 2009-09-23 22:14:34 +0000
@@ -1624,59 +1624,20 @@
The result may or may not reference the underlying inventory
so it should be treated as immutable.
"""
- interesting_parents = set()
- # TODO: Pre-pass over the list of fileids to see if anything is already
- # deserialized in self._fileid_to_entry_cache
-
- directories_to_expand = set()
- children_of_parent_id = {}
- # It is okay if some of the fileids are missing
- bytes_to_entry = self._bytes_to_entry
- for file_id, value in self.id_to_entry.iteritems(specific_fileids):
- entry = bytes_to_entry(bytes)
- if entry.kind == 'directory':
- directories_to_expand.add(file_id)
- interesting_parents.add(entry.parent_id)
- children_of_parent_id.setdefault(entry.parent_id, []).append(entry)
- # Now, interesting_parents has all of the direct parents, but not the
- # parents of those parents. It also may have some duplicates with
- # specific_fileids
- remaining_parents = interesting_parents.difference(specific_fileids)
- while remaining_parents:
- next_parents = set()
- for file_id, value in self.id_to_entry.iteritems(remaining_parents):
- entry = bytes_to_entry(bytes)
- next_parents.add(entry.parent_id)
- # Remove any search tips we've already processed
- remaining_parents = next_parents.difference(interesting_parents)
-
- # So at this point, we know all the specific_fileids that are
- # directories, and we know all of the parent ids which need to be
- # included, but not recursed
- for fileid in specific_fileids:
- ie = self.id_to_entry
- try:
- interesting_parents.update(self.get_idpath(fileid))
- except errors.NoSuchId:
- # This fileid is not in the inventory - that's ok
- pass
+ (interesting,
+ parent_to_children) = self._expand_fileids_to_parents_and_children(
+ specific_fileids)
entries = self.iter_entries()
# TODO: ???
- if self.root is None:
- return Inventory(root_id=None)
+ # if self.root is None:
+ return Inventory(root_id=None)
other = Inventory(entries.next()[1].file_id)
other.root.revision = self.root.revision
other.revision_id = self.revision_id
- directories_to_expand = set()
for path, entry in entries:
file_id = entry.file_id
- if (file_id in specific_fileids
- or entry.parent_id in directories_to_expand):
- if entry.kind == 'directory':
- directories_to_expand.add(file_id)
- elif file_id not in interesting_parents:
- continue
- other.add(entry.copy())
+ if file_id in interesting:
+ other.add(entry.copy())
return other
@staticmethod
=== modified file 'bzrlib/tests/per_inventory/__init__.py'
--- a/bzrlib/tests/per_inventory/__init__.py 2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_inventory/__init__.py 2009-09-23 22:14:34 +0000
@@ -16,15 +16,29 @@
"""Tests for different inventory implementations"""
-from bzrlib.tests import multiply_tests
+from bzrlib import (
+ groupcompress,
+ tests,
+ transport,
+ )
def load_tests(basic_tests, module, loader):
"""Generate suite containing all parameterized tests"""
modules_to_test = [
'bzrlib.tests.per_inventory.basics',
]
- from bzrlib.inventory import Inventory
- scenarios = [('Inventory', {'inventory_class':Inventory})]
+ from bzrlib.inventory import Inventory, CHKInventory
+ scenarios = [('Inventory', {'inventory_class': Inventory,
+ 'to_inventory': lambda x: x
+ }),
+ ('CHKInventory', {'inventory_class':CHKInventory,
+ 'to_inventory': CHKInventory.from_inventory
+ })]
# add the tests for the sub modules
- return multiply_tests(loader.loadTestsFromModuleNames(modules_to_test),
+ return tests.multiply_tests(
+ loader.loadTestsFromModuleNames(modules_to_test),
scenarios, basic_tests)
+
+
+class TestCaseWithInventory(tests.TestCase):
+
More information about the bazaar-commits
mailing list