~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Andrew Bennetts
  • Date: 2009-10-07 08:17:25 UTC
  • mto: This revision was merged to the branch mainline in revision 4734.
  • Revision ID: andrew.bennetts@canonical.com-20091007081725-4t3vkhher69a4k0j
Refactor to reduce duplication.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
from bzrlib.decorators import needs_read_lock, needs_write_lock
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
2111
2112
        self.control_files = _control_files
2112
2113
        self._transport = _control_files._transport
2113
2114
        self.repository = _repository
2114
 
        self._prev_lock = None
2115
2115
        Branch.__init__(self)
2116
2116
 
2117
2117
    def __str__(self):
2132
2132
        return self.control_files.is_locked()
2133
2133
 
2134
2134
    def lock_write(self, token=None):
2135
 
        if 'relock' in debug.debug_flags:
2136
 
            if not self.is_locked() and self._prev_lock == 'w':
2137
 
                note('%r was write locked again', self)
2138
 
            self._prev_lock = 'w'
 
2135
        if not self.is_locked():
 
2136
            self._note_lock('w')
2139
2137
        # All-in-one needs to always unlock/lock.
2140
2138
        repo_control = getattr(self.repository, 'control_files', None)
2141
2139
        if self.control_files == repo_control or not self.is_locked():
2151
2149
            raise
2152
2150
 
2153
2151
    def lock_read(self):
2154
 
        if 'relock' in debug.debug_flags:
2155
 
            if not self.is_locked() and self._prev_lock == 'r':
2156
 
                note('%r was read locked again', self)
2157
 
            self._prev_lock = 'r'
 
2152
        if not self.is_locked():
 
2153
            self._note_lock('r')
2158
2154
        # All-in-one needs to always unlock/lock.
2159
2155
        repo_control = getattr(self.repository, 'control_files', None)
2160
2156
        if self.control_files == repo_control or not self.is_locked():