/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/repository.py

  • Committer: John Arbash Meinel
  • Date: 2010-04-22 19:05:14 UTC
  • mfrom: (4634.139.10 2.0.6-peak-commit-mem)
  • mto: This revision was merged to the branch mainline in revision 5175.
  • Revision ID: john@arbash-meinel.com-20100422190514-udvjsm6n2a6sh0jv
Bring into bzr.dev, and update NEWS.

I can't land in 2.0 right now because PQM is broken.
But at least I can land in trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
860
860
        # versioned roots do not change unless the tree found a change.
861
861
 
862
862
 
863
 
class RepositoryWriteLockResult(object):
864
 
    """The result of write locking a repository.
865
 
 
866
 
    :ivar repository_token: The token obtained from the underlying lock, or
867
 
        None.
868
 
    :ivar unlock: A callable which will unlock the lock.
869
 
    """
870
 
 
871
 
    def __init__(self, unlock, repository_token):
872
 
        self.repository_token = repository_token
873
 
        self.unlock = unlock
874
 
 
875
 
 
876
863
######################################################################
877
864
# Repositories
878
865
 
879
866
 
880
 
class Repository(_RelockDebugMixin, bzrdir.ControlComponent):
 
867
class Repository(_RelockDebugMixin):
881
868
    """Repository holding history for one or more branches.
882
869
 
883
870
    The repository holds and retrieves historical information including
1304
1291
 
1305
1292
        :param _format: The format of the repository on disk.
1306
1293
        :param a_bzrdir: The BzrDir of the repository.
 
1294
 
 
1295
        In the future we will have a single api for all stores for
 
1296
        getting file texts, inventories and revisions, then
 
1297
        this construct will accept instances of those things.
1307
1298
        """
1308
 
        # In the future we will have a single api for all stores for
1309
 
        # getting file texts, inventories and revisions, then
1310
 
        # this construct will accept instances of those things.
1311
1299
        super(Repository, self).__init__()
1312
1300
        self._format = _format
1313
1301
        # the following are part of the public API for Repository:
1328
1316
        # rather copying them?
1329
1317
        self._safe_to_return_from_cache = False
1330
1318
 
1331
 
    @property
1332
 
    def user_transport(self):
1333
 
        return self.bzrdir.user_transport
1334
 
 
1335
 
    @property
1336
 
    def control_transport(self):
1337
 
        return self._transport
1338
 
 
1339
1319
    def __repr__(self):
1340
1320
        if self._fallback_repositories:
1341
1321
            return '%s(%r, fallback_repositories=%r)' % (
1389
1369
        data during reads, and allows a 'write_group' to be obtained. Write
1390
1370
        groups must be used for actual data insertion.
1391
1371
 
1392
 
        A token should be passed in if you know that you have locked the object
1393
 
        some other way, and need to synchronise this object's state with that
1394
 
        fact.
1395
 
 
1396
 
        XXX: this docstring is duplicated in many places, e.g. lockable_files.py
1397
 
 
1398
1372
        :param token: if this is already locked, then lock_write will fail
1399
1373
            unless the token matches the existing lock.
1400
1374
        :returns: a token if this instance supports tokens, otherwise None.
1403
1377
        :raises MismatchedToken: if the specified token doesn't match the token
1404
1378
            of the existing lock.
1405
1379
        :seealso: start_write_group.
1406
 
        :return: A RepositoryWriteLockResult.
 
1380
 
 
1381
        A token should be passed in if you know that you have locked the object
 
1382
        some other way, and need to synchronise this object's state with that
 
1383
        fact.
 
1384
 
 
1385
        XXX: this docstring is duplicated in many places, e.g. lockable_files.py
1407
1386
        """
1408
1387
        locked = self.is_locked()
1409
 
        token = self.control_files.lock_write(token=token)
 
1388
        result = self.control_files.lock_write(token=token)
1410
1389
        if not locked:
1411
1390
            self._warn_if_deprecated()
1412
1391
            self._note_lock('w')
1414
1393
                # Writes don't affect fallback repos
1415
1394
                repo.lock_read()
1416
1395
            self._refresh_data()
1417
 
        return RepositoryWriteLockResult(self.unlock, token)
 
1396
        return result
1418
1397
 
1419
1398
    def lock_read(self):
1420
 
        """Lock the repository for read operations.
1421
 
 
1422
 
        :return: An object with an unlock method which will release the lock
1423
 
            obtained.
1424
 
        """
1425
1399
        locked = self.is_locked()
1426
1400
        self.control_files.lock_read()
1427
1401
        if not locked:
1430
1404
            for repo in self._fallback_repositories:
1431
1405
                repo.lock_read()
1432
1406
            self._refresh_data()
1433
 
        return self
1434
1407
 
1435
1408
    def get_physical_lock_status(self):
1436
1409
        return self.control_files.get_physical_lock_status()
1496
1469
 
1497
1470
        # now gather global repository information
1498
1471
        # XXX: This is available for many repos regardless of listability.
1499
 
        if self.user_transport.listable():
 
1472
        if self.bzrdir.root_transport.listable():
1500
1473
            # XXX: do we want to __define len__() ?
1501
1474
            # Maybe the versionedfiles object should provide a different
1502
1475
            # method to get the number of keys.
1534
1507
 
1535
1508
        ret = []
1536
1509
        for branches, repository in bzrdir.BzrDir.find_bzrdirs(
1537
 
                self.user_transport, evaluate=Evaluator()):
 
1510
                self.bzrdir.root_transport, evaluate=Evaluator()):
1538
1511
            if branches is not None:
1539
1512
                ret.extend(branches)
1540
1513
            if not using and repository is not None: