Rev 3894: Raise if CachingParentsProvider.enable_cache used wrongly (abentley) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Dec 11 17:46:50 GMT 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3894
revision-id: pqm at pqm.ubuntu.com-20081211174647-l45s6xsw669ovgsa
parent: pqm at pqm.ubuntu.com-20081211075753-m1ktaz1at8oxlp00
parent: aaron at aaronbentley.com-20081211162546-a1zte4t2ststz6th
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-12-11 17:46:47 +0000
message:
  Raise if CachingParentsProvider.enable_cache used wrongly (abentley)
modified:
  bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
  bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
    ------------------------------------------------------------
    revno: 3835.1.20
    revision-id: aaron at aaronbentley.com-20081211162546-a1zte4t2ststz6th
    parent: aaron at aaronbentley.com-20081211032844-m23vj0emra6btb6i
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: remote-stacking-graph
    timestamp: Thu 2008-12-11 08:25:46 -0800
    message:
      Change custom error to an AssertionError.
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
      bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
    ------------------------------------------------------------
    revno: 3835.1.19
    revision-id: aaron at aaronbentley.com-20081211032844-m23vj0emra6btb6i
    parent: aaron at aaronbentley.com-20081210203113-ooeh6z6uavoysoc9
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: remote-stacking-graph
    timestamp: Wed 2008-12-10 19:28:44 -0800
    message:
      Raise exception when caching is enabled twice.
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
      bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2008-12-10 19:40:42 +0000
+++ b/bzrlib/graph.py	2008-12-11 16:25:46 +0000
@@ -134,6 +134,8 @@
 
     def enable_cache(self, cache_misses=True):
         """Enable cache."""
+        if self._cache is not None:
+            raise AssertionError('Cache enabled when already enabled.')
         self._cache = {}
         self._cache_misses = cache_misses
         if self._debug:

=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py	2008-12-10 19:40:42 +0000
+++ b/bzrlib/tests/test_graph.py	2008-12-11 16:25:46 +0000
@@ -1454,12 +1454,17 @@
         self.caching_pp.disable_cache()
         self.assertIs(None, self.caching_pp._cache)
 
+    def test_enable_cache_raises(self):
+        e = self.assertRaises(AssertionError, self.caching_pp.enable_cache)
+        self.assertEqual('Cache enabled when already enabled.', str(e))
+
     def test_cache_misses(self):
         self.caching_pp.get_parent_map(['rev3'])
         self.caching_pp.get_parent_map(['rev3'])
         self.assertEqual(['rev3'], self.inst_pp.calls)
 
     def test_no_cache_misses(self):
+        self.caching_pp.disable_cache()
         self.caching_pp.enable_cache(cache_misses=False)
         self.caching_pp.get_parent_map(['rev3'])
         self.caching_pp.get_parent_map(['rev3'])




More information about the bazaar-commits mailing list