274
277
def lock_read(self):
275
278
# wrong eventually - want a local lock cache context
279
if not self._lock_mode:
280
self._lock_mode = 'r'
283
self._lock_count += 1
276
284
self._ensure_real()
277
285
return self._real_repository.lock_read()
279
def lock_write(self):
287
def lock_write(self, token=None):
280
288
# definately wrong: want to check if there is a real repo
281
289
# and not thunk through if not
283
return self._real_repository.lock_write()
290
if not self._lock_mode:
292
self._lock_token = self._real_repository.lock_write(token=token)
293
self._lock_mode = 'w'
295
elif self._lock_mode == 'r':
296
raise errors.ReadOnlyTransaction
298
self._lock_count += 1
299
return self._lock_token
301
def leave_lock_in_place(self):
302
self._real_repository.leave_lock_in_place()
304
def dont_leave_lock_in_place(self):
305
self._real_repository.dont_leave_lock_in_place()
307
def _set_real_repository(self, repository):
308
"""Set the _real_repository for this repository.
310
:param repository: The repository to fallback to for non-hpss
311
implemented operations.
313
self._real_repository = repository
314
if self._lock_mode == 'w':
315
# if we are already locked, the real repository must be able to
316
# acquire the lock with our token.
317
self._real_repository.lock_write(self._lock_token)
285
319
def unlock(self):
286
320
# should free cache context.
287
return self._real_repository.unlock()
321
self._lock_count -= 1
322
if not self._lock_count:
323
self._lock_mode = None
324
self._lock_token = None
325
return self._real_repository.unlock()
289
327
def break_lock(self):
290
328
# should hand off to the network - or better yet, we should not
370
408
assert vfs.vfs_enabled()
371
409
self.bzrdir._ensure_real()
372
410
self._real_branch = self.bzrdir._real_bzrdir.open_branch()
373
# give the repository the matching file level repo.
374
self.repository._real_repository = self._real_branch.repository
375
# give the branch the remote repository to let fast-pathing happen
411
# Give the remote repository the matching real repo.
412
self.repository._set_real_repository(self._real_branch.repository)
413
# Give the branch the remote repository to let fast-pathing happen.
376
414
self._real_branch.repository = self.repository
378
416
def get_physical_lock_status(self):
385
423
self._ensure_real()
386
424
return self._real_branch.lock_read()
388
def lock_write(self):
426
def lock_write(self, token=None):
389
427
self._ensure_real()
390
return self._real_branch.lock_write()
428
return self._real_branch.lock_write(token=token)
392
430
def unlock(self):
393
431
self._ensure_real()