コード例 #1
0
ファイル: memorytree.py プロジェクト: pombreda/dist-packages
 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)
     except:
         self._locks -= 1
         raise
コード例 #2
0
ファイル: weaverepo.py プロジェクト: saminigod/cygwin
 def add_lines(self, key, parents, lines):
     """Add a revision to the store."""
     if not self._is_locked():
         raise errors.ObjectNotLocked(self)
     if not self._can_write():
         raise errors.ReadOnlyError(self)
     if '/' in key[-1]:
         raise ValueError('bad idea to put / in %r' % (key, ))
     text = ''.join(lines)
     if self._compressed:
         text = bytes_to_gzip(text)
     path = self._map(key)
     self._transport.put_bytes_non_atomic(path,
                                          text,
                                          create_parent_dir=True)
コード例 #3
0
ファイル: counted_lock.py プロジェクト: Techlord-RCE/cygwin
    def lock_write(self, token=None):
        """Acquire the lock in write mode.

        If the lock was originally acquired in read mode this will fail.

        :param token: If non-None, reacquire the lock using this token.
        """
        if self._lock_count == 0:
            return_token = self._real_lock.lock_write(token)
            self._lock_mode = 'w'
            self._lock_count += 1
            return return_token
        elif self._lock_mode != 'w':
            raise errors.ReadOnlyError(self)
        else:
            self._real_lock.validate_token(token)
            self._lock_count += 1
            return token
コード例 #4
0
    def lock_write(self, token=None):
        """Acquire the lock in write mode.

        If the lock was originally acquired in read mode this will fail.

        :param token: If given and the lock is already held, 
            then validate that we already hold the real
            lock with this token.

        :returns: The token from the underlying lock.
        """
        if self._lock_count == 0:
            self._token = self._real_lock.lock_write(token=token)
            self._lock_mode = 'w'
            self._lock_count += 1
            return self._token
        elif self._lock_mode != 'w':
            raise errors.ReadOnlyError(self)
        else:
            self._real_lock.validate_token(token)
            self._lock_count += 1
            return self._token