~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Robert Collins
  • Date: 2010-05-11 08:36:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100511083616-b8fjb19zomwupid0
Make all lock methods return Result objects, rather than lock_read returning self, as per John's review.

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