~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Martin Pool
  • Date: 2008-09-15 05:16:17 UTC
  • mto: (3697.2.6 261315-into-1.7)
  • mto: This revision was merged to the branch mainline in revision 3710.
  • Revision ID: mbp@sourcefrog.net-20080915051617-4wynqee2yyy1kb0y
Factor out RemoteBranch._remote_path() and disable RemoteBranch stacking

Show diffs side-by-side

added added

removed removed

Lines of Context:
1289
1289
 
1290
1290
    def _setup_stacking(self):
1291
1291
        # configure stacking into the remote repository, by reading it from
1292
 
        # the vfs branch.  note that this currently implicitly creates a
1293
 
        # _real_branch so will block getting rid of vfs until the operation is
1294
 
        # done at a higher level.
 
1292
        # the vfs branch.
 
1293
        return
1295
1294
        try:
1296
1295
            fallback_url = self.get_stacked_on_url()
 
1296
            if fallback_url is None:
 
1297
                return
1297
1298
            # it's relative to this branch...
1298
1299
            fallback_url = urlutils.join(self.base, fallback_url)
1299
 
            fallback_repo = BzrDir.open(fallback_url,
1300
 
                [self.bzrdir.root_transport,
1301
 
                 self._real_branch._transport]).open_repository()
 
1300
            transports = [self.bzrdir.root_transport]
 
1301
            if self._real_branch is not None:
 
1302
                transports.append(self._real_branch._transport)
 
1303
            fallback_bzrdir = BzrDir.open(fallback_url, transports)
 
1304
            fallback_repo = fallback_bzrdir.open_repository()
1302
1305
            self.repository.add_fallback_repository(fallback_repo)
1303
1306
        except (errors.NotStacked, errors.UnstackableBranchFormat,
1304
1307
            errors.UnstackableRepositoryFormat), e:
1387
1390
        :raises UnstackableRepositoryFormat: If the repository does not support
1388
1391
            stacking.
1389
1392
        """
1390
 
        self._ensure_real()
1391
 
        return self._real_branch.get_stacked_on_url()
 
1393
        if True:
 
1394
            self._ensure_real()
 
1395
            return self._real_branch.get_stacked_on_url()
 
1396
        else:
 
1397
            response = self._client.call('Branch.get_stacked_on_url',
 
1398
                self._remote_path())
 
1399
            if response[0] != 'ok':
 
1400
                raise errors.UnexpectedSmartServerResponse(response)
 
1401
            return response[1]
1392
1402
 
1393
1403
    def lock_read(self):
1394
1404
        if not self._lock_mode:
1406
1416
            branch_token = token
1407
1417
            repo_token = self.repository.lock_write()
1408
1418
            self.repository.unlock()
1409
 
        path = self.bzrdir._path_for_remote_call(self._client)
1410
1419
        try:
1411
1420
            response = self._client.call(
1412
 
                'Branch.lock_write', path, branch_token, repo_token or '')
 
1421
                'Branch.lock_write', self._remote_path(),
 
1422
                branch_token, repo_token or '')
1413
1423
        except errors.ErrorFromSmartServer, err:
1414
1424
            self._translate_error(err, token=token)
1415
1425
        if response[0] != 'ok':
1457
1467
        return self._lock_token or None
1458
1468
 
1459
1469
    def _unlock(self, branch_token, repo_token):
1460
 
        path = self.bzrdir._path_for_remote_call(self._client)
1461
1470
        try:
1462
 
            response = self._client.call('Branch.unlock', path, branch_token,
 
1471
            response = self._client.call('Branch.unlock', self._remote_path(), branch_token,
1463
1472
                                         repo_token or '')
1464
1473
        except errors.ErrorFromSmartServer, err:
1465
1474
            self._translate_error(err, token=str((branch_token, repo_token)))
1510
1519
        self._leave_lock = False
1511
1520
 
1512
1521
    def _last_revision_info(self):
1513
 
        path = self.bzrdir._path_for_remote_call(self._client)
1514
 
        response = self._client.call('Branch.last_revision_info', path)
 
1522
        response = self._client.call('Branch.last_revision_info', self._remote_path())
1515
1523
        if response[0] != 'ok':
1516
1524
            raise SmartProtocolError('unexpected response code %s' % (response,))
1517
1525
        revno = int(response[1])
1520
1528
 
1521
1529
    def _gen_revision_history(self):
1522
1530
        """See Branch._gen_revision_history()."""
1523
 
        path = self.bzrdir._path_for_remote_call(self._client)
1524
1531
        response_tuple, response_handler = self._client.call_expecting_body(
1525
 
            'Branch.revision_history', path)
 
1532
            'Branch.revision_history', self._remote_path())
1526
1533
        if response_tuple[0] != 'ok':
1527
1534
            raise errors.UnexpectedSmartServerResponse(response_tuple)
1528
1535
        result = response_handler.read_body_bytes().split('\x00')
1530
1537
            return []
1531
1538
        return result
1532
1539
 
 
1540
    def _remote_path(self):
 
1541
        return self.bzrdir._path_for_remote_call(self._client)
 
1542
 
1533
1543
    def _set_last_revision_descendant(self, revision_id, other_branch,
1534
1544
            allow_diverged=False, allow_overwrite_descendant=False):
1535
 
        path = self.bzrdir._path_for_remote_call(self._client)
1536
1545
        try:
1537
1546
            response = self._client.call('Branch.set_last_revision_ex',
1538
 
                path, self._lock_token, self._repo_lock_token, revision_id,
 
1547
                self._remote_path(), self._lock_token, self._repo_lock_token, revision_id,
1539
1548
                int(allow_diverged), int(allow_overwrite_descendant))
1540
1549
        except errors.ErrorFromSmartServer, err:
1541
1550
            self._translate_error(err, other_branch=other_branch)
1547
1556
        self._real_branch._last_revision_info_cache = new_revno, new_revision_id
1548
1557
 
1549
1558
    def _set_last_revision(self, revision_id):
1550
 
        path = self.bzrdir._path_for_remote_call(self._client)
1551
1559
        self._clear_cached_state()
1552
1560
        try:
1553
1561
            response = self._client.call('Branch.set_last_revision',
1554
 
                path, self._lock_token, self._repo_lock_token, revision_id)
 
1562
                self._remote_path(), self._lock_token, self._repo_lock_token, revision_id)
1555
1563
        except errors.ErrorFromSmartServer, err:
1556
1564
            self._translate_error(err)
1557
1565
        if response != ('ok',):
1626
1634
    @needs_write_lock
1627
1635
    def set_last_revision_info(self, revno, revision_id):
1628
1636
        revision_id = ensure_null(revision_id)
1629
 
        path = self.bzrdir._path_for_remote_call(self._client)
1630
1637
        try:
1631
1638
            response = self._client.call('Branch.set_last_revision_info',
1632
 
                path, self._lock_token, self._repo_lock_token, str(revno), revision_id)
 
1639
                self._remote_path(), self._lock_token, self._repo_lock_token, str(revno), revision_id)
1633
1640
        except errors.UnknownSmartMethod:
1634
1641
            self._ensure_real()
1635
1642
            self._clear_cached_state_of_remote_branch_only()