/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/lockable_files.py

  • Committer: Andrew Bennetts
  • Date: 2007-04-11 13:35:32 UTC
  • mto: (2018.5.146 hpss)
  • mto: This revision was merged to the branch mainline in revision 2414.
  • Revision ID: andrew.bennetts@canonical.com-20070411133532-u6x6edf3dmzamnaq
LockDir, Repository and Branch lock token changes from the hpss branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
            raise errors.BzrBadParameterNotString(a_string)
223
223
        self.put_bytes(path, a_string.encode('utf-8'))
224
224
 
 
225
    def leave_in_place(self):
 
226
        """Set this LockableFiles to not clear the physical lock on unlock."""
 
227
        self._lock.leave_in_place()
 
228
 
 
229
    def dont_leave_in_place(self):
 
230
        """Set this LockableFiles to clear the physical lock on unlock."""
 
231
        # XXX: think about renaming this!
 
232
        self._lock.dont_leave_in_place()
 
233
 
225
234
    def lock_write(self, token=None):
226
235
        """Lock this group of files for writing.
227
236
        
232
241
            instance doesn't support using token locks.
233
242
        :raises MismatchedToken: if the specified token doesn't match the token
234
243
            of the existing lock.
235
 
 
236
 
        A token should be passed in if you know that you have locked the object
237
 
        some other way, and need to synchronise this object's state with that
238
 
        fact.  For instance, this could happen when accessing the same branch
239
 
        over bzr+ssh:// and then falling back to do some operations on the same
240
 
        branch via sftp://.
241
244
        """
242
245
        # mutter("lock write: %s (%s)", self, self._lock_count)
243
246
        # TODO: Upgrade locking to support using a Transport,
247
250
                raise errors.ReadOnlyError(self)
248
251
            self._lock.validate_token(token)
249
252
            self._lock_count += 1
 
253
            return self._token_from_lock
250
254
        else:
251
255
            token_from_lock = self._lock.lock_write(token=token)
252
256
            #note('write locking %s', self)
254
258
            self._lock_mode = 'w'
255
259
            self._lock_count = 1
256
260
            self._set_transaction(transactions.WriteTransaction())
 
261
            # XXX: add test for the case that requires self._token_from_lock:
 
262
            # token = x.lock_write(); assert(x.lock_write() == token)
 
263
            self._token_from_lock = token_from_lock
257
264
            return token_from_lock
258
265
 
259
266
    def lock_read(self):
351
358
    def break_lock(self):
352
359
        raise NotImplementedError(self.break_lock)
353
360
 
 
361
    def leave_in_place(self):
 
362
        raise NotImplementedError(self.leave_in_place)
 
363
 
 
364
    def dont_leave_in_place(self):
 
365
        raise NotImplementedError(self.dont_leave_in_place)
 
366
 
354
367
    def lock_write(self, token=None):
355
368
        if token is not None:
356
369
            raise errors.TokenLockingNotSupported(self)