~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

  • Committer: Robert Collins
  • Date: 2006-09-15 02:03:15 UTC
  • mto: (2017.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2018.
  • Revision ID: robertc@robertcollins.net-20060915020315-9a4b022a6db42940
Update to bzr.dev, which involves adding lock_tree_write to MutableTree and MemoryTree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.symbol_versioning import DEPRECATED_PARAMETER
27
27
 
28
28
 
 
29
def needs_tree_write_lock(unbound):
 
30
    """Decorate unbound to take out and release a tree_write lock."""
 
31
    def tree_write_locked(self, *args, **kwargs):
 
32
        self.lock_tree_write()
 
33
        try:
 
34
            return unbound(self, *args, **kwargs)
 
35
        finally:
 
36
            self.unlock()
 
37
    tree_write_locked.__doc__ = unbound.__doc__
 
38
    tree_write_locked.__name__ = unbound.__name__
 
39
    return tree_write_locked
 
40
 
 
41
 
29
42
class MutableTree(tree.Tree):
30
43
    """A MutableTree is a specialisation of Tree which is able to be mutated.
31
44
 
135
148
        """
136
149
        raise NotImplementedError(self.last_revision)
137
150
 
 
151
    def lock_tree_write(self):
 
152
        """Lock the working tree for write, and the branch for read.
 
153
 
 
154
        This is useful for operations which only need to mutate the working
 
155
        tree. Taking out branch write locks is a relatively expensive process
 
156
        and may fail if the branch is on read only media. So branch write locks
 
157
        should only be taken out when we are modifying branch data - such as in
 
158
        operations like commit, pull, uncommit and update.
 
159
        """
 
160
        raise NotImplementedError(self.lock_tree_write)
 
161
 
138
162
    def lock_write(self):
139
163
        """Lock the tree and its branch. This allows mutating calls to be made.
140
164