/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/inter.py

  • Committer: Martin
  • Date: 2017-08-26 16:16:11 UTC
  • mto: This revision was merged to the branch mainline in revision 6763.
  • Revision ID: gzlist@googlemail.com-20170826161611-gzjgbcvq03u9vr38
One last dict.iteritems() in hooks tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
 
18
17
"""Inter-object utility class."""
19
18
 
 
19
from __future__ import absolute_import
 
20
 
 
21
from .errors import BzrError
 
22
 
 
23
 
 
24
class NoCompatibleInter(BzrError):
 
25
 
 
26
    _fmt = ('No compatible object available for operations from %(source)r '
 
27
            'to %(target)r.')
 
28
 
 
29
    def __init__(self, source, target):
 
30
        self.source = source
 
31
        self.target = target
 
32
 
20
33
 
21
34
class InterObject(object):
22
35
    """This class represents operations taking place between two objects.
75
88
                       the InterObject instance.
76
89
        :param target: the object to be the 'target' member of
77
90
                       the InterObject instance.
 
91
 
78
92
        If an optimised worker exists it will be used otherwise
79
93
        a default Inter worker instance will be created.
80
94
        """
81
95
        for provider in reversed(klass._optimisers):
82
96
            if provider.is_compatible(source, target):
83
97
                return provider(source, target)
84
 
        return klass(source, target)
 
98
        raise NoCompatibleInter(source, target)
85
99
 
86
100
    def lock_read(self):
87
101
        """Take out a logical read lock.