Rev 2621: Basic iter_entries working. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Fri Jul 13 12:20:48 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2621
revision-id: robertc at robertcollins.net-20070713112045-o30wjumnx9ueyoz4
parent: robertc at robertcollins.net-20070713111207-z0yrxo3g83bv5pp7
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Fri 2007-07-13 21:20:45 +1000
message:
Basic iter_entries working.
modified:
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/tests/test_index.py test_index.py-20070712131115-lolkarso50vjr64s-2
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2007-07-13 11:12:07 +0000
+++ b/bzrlib/index.py 2007-07-13 11:20:45 +0000
@@ -241,11 +241,15 @@
defined order for the result iteration - it will be in the most
efficient order for the index.
"""
- if not keys:
- return
- if False:
- yield None
- raise errors.MissingKey(self, keys[0])
+ found = set()
+ keys = set(keys)
+ for node in self.iter_all_entries():
+ if node[0] in keys:
+ yield node
+ found.add(node[0])
+ missing = keys.difference(found)
+ if missing:
+ raise errors.MissingKey(self, missing.pop())
def _signature(self):
"""The file signature for this index type."""
=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py 2007-07-13 11:12:07 +0000
+++ b/bzrlib/tests/test_index.py 2007-07-13 11:20:45 +0000
@@ -250,6 +250,14 @@
set(index.iter_all_entries()))
def test_iter_nothing_empty(self):
+ index = self.make_index(1, nodes=[
+ ('name', (['ref'], ), 'data'),
+ ('ref', ([], ), 'refdata')])
+ self.assertEqual(set([('name', (('ref',),), 'data'),
+ ('ref', ((), ), 'refdata')]),
+ set(index.iter_entries(['name', 'ref'])))
+
+ def test_iter_all_keys(self):
index = self.make_index()
self.assertEqual([], list(index.iter_entries([])))
More information about the bazaar-commits
mailing list