def lock_write(self, token=None): if token is not None: raise errors.TokenLockingNotSupported(self) if self._lock_mode is not None: if self._lock_mode != 'w': raise errors.ReadOnlyError(self) self._lock_count += 1 else: self._lock_mode = 'w' self._lock = self._hgrepo.wlock(wait=False) self._transaction = transactions.PassThroughTransaction() self._lock_count = 1
def lock_write(self): """See MutableTree.lock_write().""" self._locks += 1 try: if self._locks == 1: self.branch.lock_write() self._lock_mode = "w" self._populate_from_branch() elif self._lock_mode == "r": raise errors.ReadOnlyError(self) return lock.LogicalLockResult(self.unlock) except BaseException: self._locks -= 1 raise