~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.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:
72
72
from bzrlib.lockdir import LockDir
73
73
from bzrlib.merge import merge_inner, transform_tree
74
74
import bzrlib.mutabletree
 
75
from bzrlib.mutabletree import needs_tree_write_lock
75
76
from bzrlib.osutils import (
76
77
                            abspath,
77
78
                            compact_date,
160
161
    return gen_file_id('TREE_ROOT')
161
162
 
162
163
 
163
 
def needs_tree_write_lock(unbound):
164
 
    """Decorate unbound to take out and release a tree_write lock."""
165
 
    def tree_write_locked(self, *args, **kwargs):
166
 
        self.lock_tree_write()
167
 
        try:
168
 
            return unbound(self, *args, **kwargs)
169
 
        finally:
170
 
            self.unlock()
171
 
    tree_write_locked.__doc__ = unbound.__doc__
172
 
    tree_write_locked.__name__ = unbound.__name__
173
 
    return tree_write_locked
174
 
 
175
 
 
176
164
class TreeEntry(object):
177
165
    """An entry that implements the minimum interface used by commands.
178
166
 
1350
1338
            raise
1351
1339
 
1352
1340
    def lock_tree_write(self):
1353
 
        """Lock the working tree for write, and the branch for read.
1354
 
 
1355
 
        This is useful for operations which only need to mutate the working
1356
 
        tree. Taking out branch write locks is a relatively expensive process
1357
 
        and may fail if the branch is on read only media. So branch write locks
1358
 
        should only be taken out when we are modifying branch data - such as in
1359
 
        operations like commit, pull, uncommit and update.
1360
 
        """
 
1341
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
1361
1342
        self.branch.lock_read()
1362
1343
        try:
1363
1344
            return self._control_files.lock_write()