Rev 2629: Merge index API change. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Fri Jul 13 17:42:14 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2629
revision-id: robertc at robertcollins.net-20070713164209-1p6ng85f0ca9r4b4
parent: robertc at robertcollins.net-20070713154654-5x2rsbcf5k8nt2n4
parent: robertc at robertcollins.net-20070713163554-ok2qtnzv6rcbpt3z
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sat 2007-07-14 02:42:09 +1000
message:
  Merge index API change.
modified:
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
  bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
  bzrlib/tests/test_index.py     test_index.py-20070712131115-lolkarso50vjr64s-2
    ------------------------------------------------------------
    revno: 2626.1.1
    revision-id: robertc at robertcollins.net-20070713163554-ok2qtnzv6rcbpt3z
    parent: robertc at robertcollins.net-20070713150536-hqtkufys7aiqxl1t
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: index
    timestamp: Sat 2007-07-14 02:35:54 +1000
    message:
      Change the missing key interface in index operations to not raise, allowing callers to set policy.
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
      bzrlib/tests/test_index.py     test_index.py-20070712131115-lolkarso50vjr64s-2
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2007-07-13 14:19:21 +0000
+++ b/bzrlib/errors.py	2007-07-13 16:35:54 +0000
@@ -1599,16 +1599,6 @@
         self.msg = msg
 
 
-class MissingKey(BzrError):
-
-    _fmt = "The key %(key)s is not present in %(thing)s."
-
-    def __init__(self, thing, key):
-        BzrError.__init__(self)
-        self.thing = thing
-        self.key = key
-
-
 class MissingText(BzrError):
 
     _fmt = ("Branch %(base)s is missing revision"

=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py	2007-07-13 15:05:36 +0000
+++ b/bzrlib/index.py	2007-07-13 16:35:54 +0000
@@ -252,15 +252,10 @@
             defined order for the result iteration - it will be in the most
             efficient order for the index.
         """
-        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."""
@@ -309,15 +304,10 @@
             defined order for the result iteration - it will be in the most
             efficient order for the index.
         """
-        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 validate(self):
         """Validate that everything in the index can be accessed."""

=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py	2007-07-13 14:19:21 +0000
+++ b/bzrlib/tests/test_errors.py	2007-07-13 16:35:54 +0000
@@ -87,11 +87,6 @@
                          " known method in options: ['bad', 'no-eol']",
                          str(error))
 
-    def test_missing_key(self):
-        error = errors.MissingKey('container', 'a key')
-        self.assertEqualDiff("The key a key is not present in container.",
-            str(error))
-
     def test_medium_not_connected(self):
         error = errors.MediumNotConnected("a medium")
         self.assertEqualDiff(

=== modified file 'bzrlib/tests/test_index.py'
--- a/bzrlib/tests/test_index.py	2007-07-13 13:10:30 +0000
+++ b/bzrlib/tests/test_index.py	2007-07-13 16:35:54 +0000
@@ -256,7 +256,7 @@
             set(index.iter_all_entries()))
         self.assertEqual(set([('name', (('ref',),), 'data')]),
             set(index.iter_entries(['name'])))
-        self.assertRaises(errors.MissingKey, list, index.iter_entries(['ref']))
+        self.assertEqual([], list(index.iter_entries(['ref'])))
 
     def test_iter_all_keys(self):
         index = self.make_index(1, nodes=[
@@ -272,7 +272,7 @@
 
     def test_iter_missing_entry_empty(self):
         index = self.make_index()
-        self.assertRaises(errors.MissingKey, list, index.iter_entries(['a']))
+        self.assertEqual([], list(index.iter_entries(['a'])))
 
     def test_validate_bad_index_errors(self):
         trans = self.get_transport()
@@ -392,18 +392,18 @@
  
     def test_iter_missing_entry_empty(self):
         index = CombinedGraphIndex([])
-        self.assertRaises(errors.MissingKey, list, index.iter_entries(['a']))
+        self.assertEqual([], list(index.iter_entries(['a'])))
 
     def test_iter_missing_entry_one_index(self):
         index1 = self.make_index('1')
         index = CombinedGraphIndex([index1])
-        self.assertRaises(errors.MissingKey, list, index.iter_entries(['a']))
+        self.assertEqual([], list(index.iter_entries(['a'])))
 
     def test_iter_missing_entry_two_index(self):
         index1 = self.make_index('1')
         index2 = self.make_index('2')
         index = CombinedGraphIndex([index1, index2])
-        self.assertRaises(errors.MissingKey, list, index.iter_entries(['a']))
+        self.assertEqual([], list(index.iter_entries(['a'])))
  
     def test_iter_entry_present_one_index_only(self):
         index1 = self.make_index('1', nodes=[('key', (), '')])




More information about the bazaar-commits mailing list