예제 #1
0
 def lock_write(self, token=None):
     if not self._lock_mode:
         self._lock_mode = 'w'
         self._lock_count = 1
     elif self._lock_mode == 'r':
         raise errors.ReadOnlyError(self)
     else:
         self._lock_count += 1
     self.branch.lock_write()
     return lock.LogicalLockResult(self.unlock)
예제 #2
0
    def lock_read(self):
        """Lock the repository for read operations.

        :return: A breezy.lock.LogicalLockResult.
        """
        if not self._lock_mode:
            self._lock_mode = 'r'
            self._lock_count = 1
        else:
            self._lock_count += 1
        self.branch.lock_read()
        return lock.LogicalLockResult(self.unlock)
예제 #3
0
 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
예제 #4
0
    def lock_read(self):
        """Lock the memory tree for reading.

        This triggers population of data from the branch for its revision.
        """
        self._locks += 1
        try:
            if self._locks == 1:
                self.branch.lock_read()
                self._lock_mode = "r"
                self._populate_from_branch()
            return lock.LogicalLockResult(self.unlock)
        except BaseException:
            self._locks -= 1
            raise
예제 #5
0
 def lock_write(self):
     self._calls.append('lw')
     return lock.LogicalLockResult(self.unlock)
예제 #6
0
 def lock_read(self):
     self._calls.append('lr')
     return lock.LogicalLockResult(self.unlock)