/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/repofmt/pack_repo.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
    GraphIndex,
65
65
    InMemoryGraphIndex,
66
66
    )
67
 
from bzrlib.lock import LogicalLockResult
68
67
from bzrlib.repofmt.knitrepo import KnitRepository
69
68
from bzrlib.repository import (
70
69
    CommitBuilder,
2342
2341
        return self._write_lock_count
2343
2342
 
2344
2343
    def lock_write(self, token=None):
2345
 
        """Lock the repository for writes.
2346
 
 
2347
 
        :return: A bzrlib.repository.RepositoryWriteLockResult.
2348
 
        """
2349
2344
        locked = self.is_locked()
2350
2345
        if not self._write_lock_count and locked:
2351
2346
            raise errors.ReadOnlyError(self)
2363
2358
        return RepositoryWriteLockResult(self.unlock, None)
2364
2359
 
2365
2360
    def lock_read(self):
2366
 
        """Lock the repository for reads.
2367
 
 
2368
 
        :return: A bzrlib.lock.LogicalLockResult.
2369
 
        """
2370
2361
        locked = self.is_locked()
2371
2362
        if self._write_lock_count:
2372
2363
            self._write_lock_count += 1
2379
2370
            for repo in self._fallback_repositories:
2380
2371
                repo.lock_read()
2381
2372
            self._refresh_data()
2382
 
        return LogicalLockResult(self.unlock)
 
2373
        return self
2383
2374
 
2384
2375
    def leave_lock_in_place(self):
2385
2376
        # not supported - raise an error