~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inter.py

  • Committer: Aaron Bentley
  • Date: 2006-08-22 16:14:17 UTC
  • mto: (1910.2.43 format-bumps)
  • mto: This revision was merged to the branch mainline in revision 1997.
  • Revision ID: abentley@panoramicfeedback.com-20060822161417-29c1eb4790285db9
Back out inter.get changes, make optimizers an ordered list

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""Inter-object utility class."""
19
19
 
20
20
 
21
 
from bzrlib import errors
22
 
 
23
 
 
24
21
class InterObject(object):
25
22
    """This class represents operations taking place between two objects.
26
23
 
39
36
    the needs_read_lock and needs_write_lock decorators.)
40
37
    """
41
38
 
42
 
    # _optimisers = set()
43
 
    # Each concrete InterObject type should have its own optimisers set.
 
39
    # _optimisers = list()
 
40
    # Each concrete InterObject type should have its own optimisers list.
44
41
 
45
42
    def __init__(self, source, target):
46
43
        """Construct a default InterObject instance. Please use 'get'.
77
74
        If an optimised worker exists it will be used otherwise
78
75
        a default Inter worker instance will be created.
79
76
        """
80
 
        for provider in list(klass._optimisers) + [klass]:
 
77
        for provider in reversed(klass._optimisers):
81
78
            if provider.is_compatible(source, target):
82
79
                return provider(source, target)
83
 
        raise errors.NoInterWorker(source, target)
 
80
        return klass(source, target)
84
81
 
85
82
    def lock_read(self):
86
83
        """Take out a logical read lock.
101
98
    @classmethod
102
99
    def register_optimiser(klass, optimiser):
103
100
        """Register an InterObject optimiser."""
104
 
        klass._optimisers.add(optimiser)
 
101
        klass._optimisers.append(optimiser)
105
102
 
106
103
    def unlock(self):
107
104
        """Release the locks on source and target."""