~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Robert Collins
  • Date: 2009-02-27 01:02:40 UTC
  • mto: This revision was merged to the branch mainline in revision 4060.
  • Revision ID: robertc@robertcollins.net-20090227010240-35dzaxn8bah0razi
Move the fetch control attributes from Repository to RepositoryFormat.

Show diffs side-by-side

added added

removed removed

Lines of Context:
420
420
            raise AssertionError('%r is not a RemoteBzrDir' % (a_bzrdir,))
421
421
        return a_bzrdir.open_repository()
422
422
 
 
423
    def _ensure_real(self):
 
424
        if self._custom_format is None:
 
425
            self._custom_format = repository.network_format_registry.get(
 
426
                self._network_name)
 
427
 
 
428
    @property
 
429
    def _fetch_order(self):
 
430
        self._ensure_real()
 
431
        return self._custom_format._fetch_order
 
432
 
 
433
    @property
 
434
    def _fetch_uses_deltas(self):
 
435
        self._ensure_real()
 
436
        return self._custom_format._fetch_uses_deltas
 
437
 
 
438
    @property
 
439
    def _fetch_reconcile(self):
 
440
        self._ensure_real()
 
441
        return self._custom_format._fetch_reconcile
 
442
 
423
443
    def get_format_description(self):
424
444
        return 'bzr remote repository'
425
445
 
443
463
 
444
464
    @property
445
465
    def _serializer(self):
446
 
        if self._custom_format is not None:
447
 
            return self._custom_format._serializer
448
 
        elif self._network_name is not None:
449
 
            self._custom_format = repository.network_format_registry.get(
450
 
                self._network_name)
451
 
            return self._custom_format._serializer
452
 
        else:
453
 
            # We should only be getting asked for the serializer for
454
 
            # RemoteRepositoryFormat objects when the RemoteRepositoryFormat object
455
 
            # is a concrete instance for a RemoteRepository. In this case we know
456
 
            # the creating_repo and can use it to supply the serializer.
457
 
            self._creating_repo._ensure_real()
458
 
            return self._creating_repo._real_repository._format._serializer
 
466
        self._ensure_real()
 
467
        return self._custom_format._serializer
459
468
 
460
469
 
461
470
class RemoteRepository(_RpcHelper):
1042
1051
        self._ensure_real()
1043
1052
        return self._real_repository.iter_files_bytes(desired_files)
1044
1053
 
1045
 
    @property
1046
 
    def _fetch_order(self):
1047
 
        """Decorate the real repository for now.
1048
 
 
1049
 
        In the long term getting this back from the remote repository as part
1050
 
        of open would be more efficient.
1051
 
        """
1052
 
        self._ensure_real()
1053
 
        return self._real_repository._fetch_order
1054
 
 
1055
 
    @property
1056
 
    def _fetch_uses_deltas(self):
1057
 
        """Decorate the real repository for now.
1058
 
 
1059
 
        In the long term getting this back from the remote repository as part
1060
 
        of open would be more efficient.
1061
 
        """
1062
 
        self._ensure_real()
1063
 
        return self._real_repository._fetch_uses_deltas
1064
 
 
1065
 
    @property
1066
 
    def _fetch_reconcile(self):
1067
 
        """Decorate the real repository for now.
1068
 
 
1069
 
        In the long term getting this back from the remote repository as part
1070
 
        of open would be more efficient.
1071
 
        """
1072
 
        self._ensure_real()
1073
 
        return self._real_repository._fetch_reconcile
1074
 
 
1075
1054
    def get_parent_map(self, revision_ids):
1076
1055
        """See bzrlib.Graph.get_parent_map()."""
1077
1056
        return self._make_parents_provider().get_parent_map(revision_ids)
1345
1324
        return self._real_repository.get_revisions(revision_ids)
1346
1325
 
1347
1326
    def supports_rich_root(self):
1348
 
        self._ensure_real()
1349
 
        return self._real_repository.supports_rich_root()
 
1327
        return self._format.rich_root_data
1350
1328
 
1351
1329
    def iter_reverse_revision_history(self, revision_id):
1352
1330
        self._ensure_real()
1354
1332
 
1355
1333
    @property
1356
1334
    def _serializer(self):
1357
 
        self._ensure_real()
1358
 
        return self._real_repository._serializer
 
1335
        return self._format._serializer
1359
1336
 
1360
1337
    def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
1361
1338
        self._ensure_real()
1500
1477
                    serialised = record_to_fulltext_bytes(record)
1501
1478
                else:
1502
1479
                    serialised = record.get_bytes_as(record.storage_kind)
1503
 
                pack_writer.add_bytes_record(serialised, [(substream_type,)])
 
1480
                if serialised:
 
1481
                    # Some streams embed the whole stream into the wire
 
1482
                    # representation of the first record, which means that
 
1483
                    # later records have no wire representation: we skip them.
 
1484
                    pack_writer.add_bytes_record(serialised, [(substream_type,)])
1504
1485
                for b in bytes:
1505
1486
                    yield b
1506
1487
                del bytes[:]