Rev 5840: (jelmer) Require the default for Inter.get to be explicitly registered. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon May 9 08:12:05 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5840 [merge]
revision-id: pqm at pqm.ubuntu.com-20110509081201-1nreh088nt7xh3l1
parent: pqm at pqm.ubuntu.com-20110509032323-fbl2v7298id5trxy
parent: jelmer at samba.org-20110508130752-aechnxoq7t1okc53
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-05-09 08:12:01 +0000
message:
(jelmer) Require the default for Inter.get to be explicitly registered.
(Jelmer Vernooij)
modified:
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/inter.py inter.py-20060302012326-a57300cb382c618f
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2011-04-04 12:12:57 +0000
+++ b/bzrlib/errors.py 2011-05-08 12:42:43 +0000
@@ -3249,3 +3249,13 @@
def __init__(self, name, string):
self.name = name
self.string = string
+
+
+class NoCompatibleInter(BzrError):
+
+ _fmt = ('No compatible object available for operations from %(source)r '
+ 'to %(target)r.')
+
+ def __init__(self, source, target):
+ self.source = source
+ self.target = target
=== modified file 'bzrlib/inter.py'
--- a/bzrlib/inter.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/inter.py 2011-05-08 12:42:43 +0000
@@ -18,6 +18,9 @@
"""Inter-object utility class."""
+from bzrlib.errors import NoCompatibleInter
+
+
class InterObject(object):
"""This class represents operations taking place between two objects.
@@ -81,7 +84,7 @@
for provider in reversed(klass._optimisers):
if provider.is_compatible(source, target):
return provider(source, target)
- return klass(source, target)
+ raise NoCompatibleInter(source, target)
def lock_read(self):
"""Take out a logical read lock.
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2011-05-04 04:20:20 +0000
+++ b/bzrlib/repository.py 2011-05-09 08:12:01 +0000
@@ -3552,6 +3552,15 @@
raise errors.IncompatibleRepositories(source, target,
"different serializers")
+ @classmethod
+ def _get_repo_format_to_test(self):
+ return None
+
+ @classmethod
+ def is_compatible(cls, source, target):
+ # The default implementation is compatible with everything
+ return True
+
class InterSameDataRepository(InterRepository):
"""Code for converting between repositories that represent the same data.
@@ -3913,6 +3922,7 @@
return basis_id, basis_tree
+InterRepository.register_optimiser(InterRepository)
InterRepository.register_optimiser(InterDifferingSerializer)
InterRepository.register_optimiser(InterSameDataRepository)
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2011-04-17 23:06:22 +0000
+++ b/bzrlib/tree.py 2011-05-08 12:54:20 +0000
@@ -936,6 +936,12 @@
_optimisers = []
+ @classmethod
+ def is_compatible(kls, source, target):
+ # The default implementation is naive and uses the public API, so
+ # it works for all trees.
+ return True
+
def _changes_from_entries(self, source_entry, target_entry,
source_path=None, target_path=None):
"""Generate a iter_changes tuple between source_entry and target_entry.
@@ -1310,6 +1316,9 @@
yield result
+InterTree.register_optimiser(InterTree)
+
+
class MultiWalker(object):
"""Walk multiple trees simultaneously, getting combined results."""
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-05-09 02:33:16 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-05-09 08:12:01 +0000
@@ -66,6 +66,10 @@
* ``annotate_file`` has been deprecated in favor of
``annotate_file_revision_tree``. (Jelmer Vernooij, #775598)
+* ``Inter.get`` now raises ``NoCompatibleInter`` if there are no
+ compatible optimisers rather than an instance of the class it is called
+ on. (Jelmer Vernooij)
+
Internals
*********
More information about the bazaar-commits
mailing list