~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/weave_fmt/branch.py

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    lockable_files,
24
24
    )
25
25
 
26
 
from bzrlib.decorators import (
27
 
    needs_read_lock,
28
 
    needs_write_lock,
29
 
    only_raises,
30
 
    )
31
 
from bzrlib.lock import LogicalLockResult
32
26
from bzrlib.trace import mutter
33
27
 
34
28
from bzrlib.branch import (
35
29
    BranchFormat,
36
 
    BranchWriteLockResult,
37
 
    )
38
 
from bzrlib.branchfmt.fullhistory import (
39
30
    FullHistoryBzrBranch,
40
31
    )
41
32
 
43
34
class BzrBranch4(FullHistoryBzrBranch):
44
35
    """Branch format 4."""
45
36
 
46
 
    def lock_write(self, token=None):
47
 
        """Lock the branch for write operations.
48
 
 
49
 
        :param token: A token to permit reacquiring a previously held and
50
 
            preserved lock.
51
 
        :return: A BranchWriteLockResult.
52
 
        """
53
 
        if not self.is_locked():
54
 
            self._note_lock('w')
55
 
        # All-in-one needs to always unlock/lock.
56
 
        self.repository._warn_if_deprecated(self)
57
 
        self.repository.lock_write()
58
 
        try:
59
 
            return BranchWriteLockResult(self.unlock,
60
 
                self.control_files.lock_write(token=token))
61
 
        except:
62
 
            self.repository.unlock()
63
 
            raise
64
 
 
65
 
    def lock_read(self):
66
 
        """Lock the branch for read operations.
67
 
 
68
 
        :return: A bzrlib.lock.LogicalLockResult.
69
 
        """
70
 
        if not self.is_locked():
71
 
            self._note_lock('r')
72
 
        # All-in-one needs to always unlock/lock.
73
 
        self.repository._warn_if_deprecated(self)
74
 
        self.repository.lock_read()
75
 
        try:
76
 
            self.control_files.lock_read()
77
 
            return LogicalLockResult(self.unlock)
78
 
        except:
79
 
            self.repository.unlock()
80
 
            raise
81
 
 
82
 
    @only_raises(errors.LockNotHeld, errors.LockBroken)
83
 
    def unlock(self):
84
 
        if self.control_files._lock_count == 2 and self.conf_store is not None:
85
 
            self.conf_store.save_changes()
86
 
        try:
87
 
            self.control_files.unlock()
88
 
        finally:
89
 
            # All-in-one needs to always unlock/lock.
90
 
            self.repository.unlock()
91
 
            if not self.control_files.is_locked():
92
 
                # we just released the lock
93
 
                self._clear_cached_state()
94
 
 
95
37
    def _get_checkout_format(self, lightweight=False):
96
38
        """Return the most suitable metadir for a checkout of this branch.
97
39
        """