~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-14 08:21:19 UTC
  • mfrom: (3517.4.20 stacking)
  • Revision ID: pqm@pqm.ubuntu.com-20080714082119-ju6qe5weo8pp7f1c
merge integrated branch stacking

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
            format.supports_tree_reference = (response[3] == 'yes')
182
182
            # No wire format to check this yet.
183
183
            format.supports_external_lookups = (response[4] == 'yes')
 
184
            # Used to support creating a real format instance when needed.
 
185
            format._creating_bzrdir = self
184
186
            return RemoteRepository(self, format)
185
187
        else:
186
188
            raise errors.NoRepositoryPresent(self)
239
241
 
240
242
    def initialize(self, a_bzrdir, shared=False):
241
243
        if not isinstance(a_bzrdir, RemoteBzrDir):
242
 
            raise AssertionError('%r is not a RemoteBzrDir' % (a_bzrdir,))
 
244
            prior_repo = self._creating_bzrdir.open_repository()
 
245
            prior_repo._ensure_real()
 
246
            return prior_repo._real_repository._format.initialize(
 
247
                a_bzrdir, shared=shared)
243
248
        return a_bzrdir.create_repository(shared=shared)
244
249
    
245
250
    def open(self, a_bzrdir):
308
313
        self._reconcile_fixes_text_parents = False
309
314
        self._reconcile_backsup_inventory = False
310
315
        self.base = self.bzrdir.transport.base
 
316
        # Additional places to query for data.
 
317
        self._fallback_repositories = []
311
318
 
312
319
    def __str__(self):
313
320
        return "%s(%s)" % (self.__class__.__name__, self.base)
700
707
                committer=committer, revprops=revprops, revision_id=revision_id)
701
708
        return builder
702
709
 
 
710
    def add_fallback_repository(self, repository):
 
711
        """Add a repository to use for looking up data not held locally.
 
712
        
 
713
        :param repository: A repository.
 
714
        """
 
715
        if not self._format.supports_external_lookups:
 
716
            raise errors.UnstackableRepositoryFormat(self._format, self.base)
 
717
        # We need to accumulate additional repositories here, to pass them in
 
718
        # on various RPC's.
 
719
        self._fallback_repositories.append(repository)
 
720
 
703
721
    def add_inventory(self, revid, inv, parents):
704
722
        self._ensure_real()
705
723
        return self._real_repository.add_inventory(revid, inv, parents)
1301
1319
        self._ensure_real()
1302
1320
        return self._real_branch.get_physical_lock_status()
1303
1321
 
 
1322
    def get_stacked_on(self):
 
1323
        """Get the URL this branch is stacked against.
 
1324
 
 
1325
        :raises NotStacked: If the branch is not stacked.
 
1326
        :raises UnstackableBranchFormat: If the branch does not support
 
1327
            stacking.
 
1328
        :raises UnstackableRepositoryFormat: If the repository does not support
 
1329
            stacking.
 
1330
        """
 
1331
        self._ensure_real()
 
1332
        return self._real_branch.get_stacked_on()
 
1333
 
1304
1334
    def lock_read(self):
1305
1335
        if not self._lock_mode:
1306
1336
            self._lock_mode = 'r'
1507
1537
        self._ensure_real()
1508
1538
        return self._real_branch.set_parent(url)
1509
1539
        
 
1540
    def set_stacked_on(self, stacked_location):
 
1541
        """Set the URL this branch is stacked against.
 
1542
 
 
1543
        :raises UnstackableBranchFormat: If the branch does not support
 
1544
            stacking.
 
1545
        :raises UnstackableRepositoryFormat: If the repository does not support
 
1546
            stacking.
 
1547
        """
 
1548
        self._ensure_real()
 
1549
        return self._real_branch.set_stacked_on(stacked_location)
 
1550
 
1510
1551
    def sprout(self, to_bzrdir, revision_id=None):
1511
1552
        # Like Branch.sprout, except that it sprouts a branch in the default
1512
1553
        # format, because RemoteBranches can't be created at arbitrary URLs.