~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2009-10-20 19:46:46 UTC
  • mfrom: (4759 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4771.
  • Revision ID: john@arbash-meinel.com-20091020194646-wnqpd15qs19y28z7
Merge bzr.dev 4759, bringing in static_tuple and streaming improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    )
47
47
""")
48
48
 
49
 
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
49
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
50
50
from bzrlib.hooks import HookPoint, Hooks
51
51
from bzrlib.inter import InterObject
 
52
from bzrlib.lock import _RelockDebugMixin
52
53
from bzrlib import registry
53
54
from bzrlib.symbol_versioning import (
54
55
    deprecated_in,
2079
2080
    _legacy_formats[0].network_name(), _legacy_formats[0].__class__)
2080
2081
 
2081
2082
 
2082
 
class BzrBranch(Branch):
 
2083
class BzrBranch(Branch, _RelockDebugMixin):
2083
2084
    """A branch stored in the actual filesystem.
2084
2085
 
2085
2086
    Note that it's "local" in the context of the filesystem; it doesn't
2131
2132
        return self.control_files.is_locked()
2132
2133
 
2133
2134
    def lock_write(self, token=None):
 
2135
        if not self.is_locked():
 
2136
            self._note_lock('w')
2134
2137
        # All-in-one needs to always unlock/lock.
2135
2138
        repo_control = getattr(self.repository, 'control_files', None)
2136
2139
        if self.control_files == repo_control or not self.is_locked():
2146
2149
            raise
2147
2150
 
2148
2151
    def lock_read(self):
 
2152
        if not self.is_locked():
 
2153
            self._note_lock('r')
2149
2154
        # All-in-one needs to always unlock/lock.
2150
2155
        repo_control = getattr(self.repository, 'control_files', None)
2151
2156
        if self.control_files == repo_control or not self.is_locked():
2160
2165
                self.repository.unlock()
2161
2166
            raise
2162
2167
 
 
2168
    @only_raises(errors.LockNotHeld, errors.LockBroken)
2163
2169
    def unlock(self):
2164
2170
        try:
2165
2171
            self.control_files.unlock()