~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remotebranch.py

  • Committer: Martin Pool
  • Date: 2005-05-30 01:37:52 UTC
  • Revision ID: mbp@sourcefrog.net-20050530013751-650874ded00ae1a1
- Use explicit lock methods on a branch, rather than doing it
  implicitly from the Branch constructor and relying on destroying the
  branch to release the lock.

- New with_readlock, _with_writelock decorators for branch methods.

- Branch locks can now be taken several times by a single caller, but
  they forbid upgrading or downgrading.

- Don't need assertions about whether the branch is locked anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
 
100
100
 
101
101
class RemoteBranch(Branch):
102
 
    def __init__(self, baseurl, find_root=True, lock_mode='r'):
 
102
    def __init__(self, baseurl, find_root=True):
103
103
        """Create new proxy for a remote branch."""
104
104
        if lock_mode not in ('', 'r'):
105
105
            raise BzrError('lock mode %r is not supported for remote branches'
124
124
            raise BzrError("file mode %r not supported for remote branches" % mode)
125
125
        return get_url(self.baseurl + '/.bzr/' + filename, False)
126
126
 
127
 
    def _need_readlock(self):
128
 
        # remote branch always safe for read
 
127
 
 
128
    def lock(self, mode):
 
129
        if mode != 'r':
 
130
            raise BzrError('lock mode %r not supported for remote branch %r' % (mode, self))
 
131
 
 
132
    def unlock(self):
129
133
        pass
130
 
 
131
 
    def _need_writelock(self):
132
 
        raise BzrError("cannot get write lock on HTTP remote branch")
 
134
    
133
135
 
134
136
    def relpath(self, path):
135
137
        if not path.startswith(self.baseurl):