~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Parth Malwankar
  • Date: 2010-05-05 14:11:13 UTC
  • mfrom: (5211 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5213.
  • Revision ID: parth.malwankar@gmail.com-20100505141113-c21oicoxzb3u6if6
merged in changes from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    chk_map,
27
27
    config,
28
28
    debug,
29
 
    errors,
30
29
    fetch as _mod_fetch,
31
30
    fifo_cache,
32
31
    generate_ids,
62
61
    entry_factory,
63
62
    )
64
63
from bzrlib.lock import _RelockDebugMixin
65
 
from bzrlib import registry
 
64
from bzrlib import (
 
65
    errors,
 
66
    registry,
 
67
    )
66
68
from bzrlib.trace import (
67
69
    log_exception_quietly, note, mutter, mutter_callsite, warning)
68
70
 
71
73
_deprecation_warning_done = False
72
74
 
73
75
 
 
76
class IsInWriteGroupError(errors.InternalBzrError):
 
77
 
 
78
    _fmt = "May not refresh_data of repo %(repo)s while in a write group."
 
79
 
 
80
    def __init__(self, repo):
 
81
        errors.InternalBzrError.__init__(self, repo=repo)
 
82
 
 
83
 
74
84
class CommitBuilder(object):
75
85
    """Provides an interface to build up a commit.
76
86
 
864
874
# Repositories
865
875
 
866
876
 
867
 
class Repository(_RelockDebugMixin):
 
877
class Repository(_RelockDebugMixin, bzrdir.ControlComponent):
868
878
    """Repository holding history for one or more branches.
869
879
 
870
880
    The repository holds and retrieves historical information including
1291
1301
 
1292
1302
        :param _format: The format of the repository on disk.
1293
1303
        :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.
1298
1304
        """
 
1305
        # In the future we will have a single api for all stores for
 
1306
        # getting file texts, inventories and revisions, then
 
1307
        # this construct will accept instances of those things.
1299
1308
        super(Repository, self).__init__()
1300
1309
        self._format = _format
1301
1310
        # the following are part of the public API for Repository:
1316
1325
        # rather copying them?
1317
1326
        self._safe_to_return_from_cache = False
1318
1327
 
 
1328
    @property
 
1329
    def user_transport(self):
 
1330
        return self.bzrdir.user_transport
 
1331
 
 
1332
    @property
 
1333
    def control_transport(self):
 
1334
        return self._transport
 
1335
 
1319
1336
    def __repr__(self):
1320
1337
        if self._fallback_repositories:
1321
1338
            return '%s(%r, fallback_repositories=%r)' % (
1469
1486
 
1470
1487
        # now gather global repository information
1471
1488
        # XXX: This is available for many repos regardless of listability.
1472
 
        if self.bzrdir.root_transport.listable():
 
1489
        if self.user_transport.listable():
1473
1490
            # XXX: do we want to __define len__() ?
1474
1491
            # Maybe the versionedfiles object should provide a different
1475
1492
            # method to get the number of keys.
1507
1524
 
1508
1525
        ret = []
1509
1526
        for branches, repository in bzrdir.BzrDir.find_bzrdirs(
1510
 
                self.bzrdir.root_transport, evaluate=Evaluator()):
 
1527
                self.user_transport, evaluate=Evaluator()):
1511
1528
            if branches is not None:
1512
1529
                ret.extend(branches)
1513
1530
            if not using and repository is not None:
1627
1644
        return missing_keys
1628
1645
 
1629
1646
    def refresh_data(self):
1630
 
        """Re-read any data needed to to synchronise with disk.
 
1647
        """Re-read any data needed to synchronise with disk.
1631
1648
 
1632
1649
        This method is intended to be called after another repository instance
1633
1650
        (such as one used by a smart server) has inserted data into the
1634
 
        repository. It may not be called during a write group, but may be
1635
 
        called at any other time.
 
1651
        repository. On all repositories this will work outside of write groups.
 
1652
        Some repository formats (pack and newer for bzrlib native formats)
 
1653
        support refresh_data inside write groups. If called inside a write
 
1654
        group on a repository that does not support refreshing in a write group
 
1655
        IsInWriteGroupError will be raised.
1636
1656
        """
1637
 
        if self.is_in_write_group():
1638
 
            raise errors.InternalBzrError(
1639
 
                "May not refresh_data while in a write group.")
1640
1657
        self._refresh_data()
1641
1658
 
1642
1659
    def resume_write_group(self, tokens):