492
492
raise errors.UnexpectedSmartServerResponse(response)
494
494
def unlock(self):
495
if self._lock_count == 1 and self._lock_mode == 'w':
496
# don't unlock if inside a write group.
497
if self.is_in_write_group():
498
raise errors.BzrError(
499
'Must end write groups before releasing write locks.')
500
495
self._lock_count -= 1
501
if not self._lock_count:
502
mode = self._lock_mode
503
self._lock_mode = None
496
if self._lock_count > 0:
498
old_mode = self._lock_mode
499
self._lock_mode = None
501
# The real repository is responsible at present for raising an
502
# exception if it's in an unfinished write group. However, it
503
# normally will *not* actually remove the lock from disk - that's
504
# done by the server on receiving the Repository.unlock call.
505
# This is just to let the _real_repository stay up to date.
504
506
if self._real_repository is not None:
505
507
self._real_repository.unlock()
509
# The rpc-level lock should be released even if there was a
510
# problem releasing the vfs-based lock.
507
512
# Only write-locked repositories need to make a remote method
508
513
# call to perfom the unlock.
510
assert self._lock_token, 'Locked, but no token!'
511
token = self._lock_token
512
self._lock_token = None
513
if not self._leave_lock:
514
assert self._lock_token, \
515
'%s is locked, but has no token' \
517
old_token = self._lock_token
518
self._lock_token = None
519
if not self._leave_lock:
520
self._unlock(old_token)
516
522
def break_lock(self):
517
523
# should hand off to the network