At http://people.ubuntu.com/~robertc/baz2.0/RemoteRepository._format
------------------------------------------------------------ revno: 4057 revision-id: [email protected] parent: [email protected] committer: Robert Collins <[email protected]> branch nick: RemoteRepository._format timestamp: Fri 2009-02-27 12:02:40 +1100 message: Move the fetch control attributes from Repository to RepositoryFormat. === modified file 'NEWS' --- a/NEWS 2009-02-26 11:01:20 +0000 +++ b/NEWS 2009-02-27 01:02:40 +0000 @@ -87,6 +87,11 @@ updated to comply with this. The code already complied with the other criteria, but now it is enforced. (Marius Kruger) + * The ``_fetch_*`` attributes on ``Repository`` are now on + ``RepositoryFormat``, more accurately reflecting their intent (they + describe a disk format capability, not state of a particular + repository of that format). (Robert Collins) + INTERNALS: * Branch and Repository creation on a bzr+ssh://server are now done === modified file 'bzrlib/fetch.py' --- a/bzrlib/fetch.py 2009-02-24 21:22:43 +0000 +++ b/bzrlib/fetch.py 2009-02-27 01:02:40 +0000 @@ -192,8 +192,8 @@ # Now copy the file texts. from_texts = self.from_repository.texts yield ('texts', from_texts.get_record_stream( - text_keys, self.to_repository._fetch_order, - not self.to_repository._fetch_uses_deltas)) + text_keys, self.to_repository._format._fetch_order, + not self.to_repository._format._fetch_uses_deltas)) # Cause an error if a text occurs after we have done the # copy. text_keys = None @@ -248,7 +248,7 @@ # Ask for full texts always so that we don't need more round trips # after this stream. stream = vf.get_record_stream(keys, - self.to_repository._fetch_order, True) + self.to_repository._format._fetch_order, True) yield substream_kind, stream def _revids_to_fetch(self): @@ -279,15 +279,15 @@ keys = [(rev_id,) for rev_id in revs] signatures = filter_absent(from_sf.get_record_stream( keys, - self.to_repository._fetch_order, - not self.to_repository._fetch_uses_deltas)) + self.to_repository._format._fetch_order, + not self.to_repository._format._fetch_uses_deltas)) # If a revision has a delta, this is actually expanded inside the # insert_record_stream code now, which is an alternate fix for # bug #261339 from_rf = self.from_repository.revisions revisions = from_rf.get_record_stream( keys, - self.to_repository._fetch_order, + self.to_repository._format._fetch_order, not self.delta_on_metadata()) return [('signatures', signatures), ('revisions', revisions)] @@ -301,12 +301,12 @@ return [] def inventory_fetch_order(self): - return self.to_repository._fetch_order + return self.to_repository._format._fetch_order def delta_on_metadata(self): src_serializer = self.from_repository._format._serializer target_serializer = self.to_repository._format._serializer - return (self.to_repository._fetch_uses_deltas and + return (self.to_repository._format._fetch_uses_deltas and src_serializer == target_serializer) === modified file 'bzrlib/remote.py' --- a/bzrlib/remote.py 2009-02-26 06:01:21 +0000 +++ b/bzrlib/remote.py 2009-02-27 01:02:40 +0000 @@ -420,6 +420,26 @@ raise AssertionError('%r is not a RemoteBzrDir' % (a_bzrdir,)) return a_bzrdir.open_repository() + def _ensure_real(self): + if self._custom_format is None: + self._custom_format = repository.network_format_registry.get( + self._network_name) + + @property + def _fetch_order(self): + self._ensure_real() + return self._custom_format._fetch_order + + @property + def _fetch_uses_deltas(self): + self._ensure_real() + return self._custom_format._fetch_uses_deltas + + @property + def _fetch_reconcile(self): + self._ensure_real() + return self._custom_format._fetch_reconcile + def get_format_description(self): return 'bzr remote repository' @@ -443,19 +463,8 @@ @property def _serializer(self): - if self._custom_format is not None: - return self._custom_format._serializer - elif self._network_name is not None: - self._custom_format = repository.network_format_registry.get( - self._network_name) - return self._custom_format._serializer - else: - # We should only be getting asked for the serializer for - # RemoteRepositoryFormat objects when the RemoteRepositoryFormat object - # is a concrete instance for a RemoteRepository. In this case we know - # the creating_repo and can use it to supply the serializer. - self._creating_repo._ensure_real() - return self._creating_repo._real_repository._format._serializer + self._ensure_real() + return self._custom_format._serializer class RemoteRepository(_RpcHelper): @@ -1042,36 +1051,6 @@ self._ensure_real() return self._real_repository.iter_files_bytes(desired_files) - @property - def _fetch_order(self): - """Decorate the real repository for now. - - In the long term getting this back from the remote repository as part - of open would be more efficient. - """ - self._ensure_real() - return self._real_repository._fetch_order - - @property - def _fetch_uses_deltas(self): - """Decorate the real repository for now. - - In the long term getting this back from the remote repository as part - of open would be more efficient. - """ - self._ensure_real() - return self._real_repository._fetch_uses_deltas - - @property - def _fetch_reconcile(self): - """Decorate the real repository for now. - - In the long term getting this back from the remote repository as part - of open would be more efficient. - """ - self._ensure_real() - return self._real_repository._fetch_reconcile - def get_parent_map(self, revision_ids): """See bzrlib.Graph.get_parent_map().""" return self._make_parents_provider().get_parent_map(revision_ids) @@ -1345,8 +1324,7 @@ return self._real_repository.get_revisions(revision_ids) def supports_rich_root(self): - self._ensure_real() - return self._real_repository.supports_rich_root() + return self._format.rich_root_data def iter_reverse_revision_history(self, revision_id): self._ensure_real() @@ -1354,8 +1332,7 @@ @property def _serializer(self): - self._ensure_real() - return self._real_repository._serializer + return self._format._serializer def store_revision_signature(self, gpg_strategy, plaintext, revision_id): self._ensure_real() @@ -1500,7 +1477,11 @@ serialised = record_to_fulltext_bytes(record) else: serialised = record.get_bytes_as(record.storage_kind) - pack_writer.add_bytes_record(serialised, [(substream_type,)]) + if serialised: + # Some streams embed the whole stream into the wire + # representation of the first record, which means that + # later records have no wire representation: we skip them. + pack_writer.add_bytes_record(serialised, [(substream_type,)]) for b in bytes: yield b del bytes[:] === modified file 'bzrlib/repofmt/knitrepo.py' --- a/bzrlib/repofmt/knitrepo.py 2009-01-17 01:30:58 +0000 +++ b/bzrlib/repofmt/knitrepo.py 2009-02-27 01:02:40 +0000 @@ -124,8 +124,6 @@ self._commit_builder_class = _commit_builder_class self._serializer = _serializer self._reconcile_fixes_text_parents = True - self._fetch_uses_deltas = True - self._fetch_order = 'topological' @needs_read_lock def _all_revision_ids(self): @@ -288,6 +286,8 @@ supports_ghosts = True # External lookups are not supported in this format. supports_external_lookups = False + _fetch_order = 'topological' + _fetch_uses_deltas = True def _get_inventories(self, repo_transport, repo, name='inventory'): mapper = versionedfile.ConstantMapper(name) === modified file 'bzrlib/repofmt/pack_repo.py' --- a/bzrlib/repofmt/pack_repo.py 2009-02-23 15:29:35 +0000 +++ b/bzrlib/repofmt/pack_repo.py 2009-02-27 01:02:40 +0000 @@ -2049,7 +2049,6 @@ self._reconcile_does_inventory_gc = True self._reconcile_fixes_text_parents = True self._reconcile_backsup_inventory = False - self._fetch_order = 'unordered' def _warn_if_deprecated(self): # This class isn't deprecated, but one sub-format is @@ -2250,6 +2249,7 @@ # What index classes to use index_builder_class = None index_class = None + _fetch_uses_deltas = True def initialize(self, a_bzrdir, shared=False): """Create a pack based repository. === modified file 'bzrlib/repofmt/weaverepo.py' --- a/bzrlib/repofmt/weaverepo.py 2009-02-23 15:42:47 +0000 +++ b/bzrlib/repofmt/weaverepo.py 2009-02-27 01:02:40 +0000 @@ -100,8 +100,6 @@ self.inventory_store = get_store('inventory-store') self._text_store = get_store('text-store') super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files) - self._fetch_order = 'topological' - self._fetch_reconcile = True @needs_read_lock def _all_possible_ids(self): @@ -194,8 +192,6 @@ def __init__(self, _format, a_bzrdir, control_files): super(WeaveMetaDirRepository, self).__init__(_format, a_bzrdir, control_files) - self._fetch_order = 'topological' - self._fetch_reconcile = True self._serializer = _format._serializer @needs_read_lock @@ -270,6 +266,8 @@ supports_tree_reference = False supports_ghosts = False supports_external_lookups = False + _fetch_order = 'topological' + _fetch_reconcile = True def initialize(self, a_bzrdir, shared=False, _internal=False): """Create a weave repository.""" @@ -335,11 +333,6 @@ _matchingbzrdir = bzrdir.BzrDirFormat4() - def __init__(self): - super(RepositoryFormat4, self).__init__() - self._fetch_order = 'topological' - self._fetch_reconcile = True - def get_format_description(self): """See RepositoryFormat.get_format_description().""" return "Repository format 4" @@ -391,11 +384,6 @@ def _serializer(self): return xml5.serializer_v5 - def __init__(self): - super(RepositoryFormat5, self).__init__() - self._fetch_order = 'topological' - self._fetch_reconcile = True - def get_format_description(self): """See RepositoryFormat.get_format_description().""" return "Weave repository format 5" @@ -441,11 +429,6 @@ def _serializer(self): return xml5.serializer_v5 - def __init__(self): - super(RepositoryFormat6, self).__init__() - self._fetch_order = 'topological' - self._fetch_reconcile = True - def get_format_description(self): """See RepositoryFormat.get_format_description().""" return "Weave repository format 6" @@ -490,6 +473,8 @@ _versionedfile_class = weave.WeaveFile supports_ghosts = False + _fetch_order = 'topological' + _fetch_reconcile = True @property def _serializer(self): return xml5.serializer_v5 === modified file 'bzrlib/repository.py' --- a/bzrlib/repository.py 2009-02-26 00:39:51 +0000 +++ b/bzrlib/repository.py 2009-02-27 01:02:40 +0000 @@ -830,18 +830,6 @@ self._write_group = None # Additional places to query for data. self._fallback_repositories = [] - # What order should fetch operations request streams in? - # The default is unordered as that is the cheapest for an origin to - # provide. - self._fetch_order = 'unordered' - # Does this repository use deltas that can be fetched as-deltas ? - # (E.g. knits, where the knit deltas can be transplanted intact. - # We default to False, which will ensure that enough data to get - # a full text out of any fetch stream will be grabbed. - self._fetch_uses_deltas = False - # Should fetch trigger a reconcile after the fetch? Only needed for - # some repository formats that can suffer internal inconsistencies. - self._fetch_reconcile = False # An InventoryEntry cache, used during deserialization self._inventory_entry_cache = fifo_cache.FIFOCache(10*1024) @@ -2264,6 +2252,18 @@ # Can this repository be given external locations to lookup additional # data. Set to True or False in derived classes. supports_external_lookups = None + # What order should fetch operations request streams in? + # The default is unordered as that is the cheapest for an origin to + # provide. + _fetch_order = 'unordered' + # Does this repository format use deltas that can be fetched as-deltas ? + # (E.g. knits, where the knit deltas can be transplanted intact. + # We default to False, which will ensure that enough data to get + # a full text out of any fetch stream will be grabbed. + _fetch_uses_deltas = False + # Should fetch trigger a reconcile after the fetch? Only needed for + # some repository formats that can suffer internal inconsistencies. + _fetch_reconcile = False def __str__(self): return "<%s>" % self.__class__.__name__ @@ -3293,8 +3293,8 @@ from_texts = self.source.texts to_texts = self.target.texts to_texts.insert_record_stream(from_texts.get_record_stream( - text_keys, self.target._fetch_order, - not self.target._fetch_uses_deltas)) + text_keys, self.target._format._fetch_order, + not self.target._format._fetch_uses_deltas)) # insert deltas for delta in pending_deltas: self.target.add_inventory_by_delta(*delta) @@ -3476,8 +3476,8 @@ from bzrlib.repofmt.pack_repo import RepositoryFormatPack if isinstance(source._format, RepositoryFormatPack): if isinstance(target, remote.RemoteRepository): - target._ensure_real() - if isinstance(target._real_repository._format, + target._format._ensure_real() + if isinstance(target._format._custom_format, RepositoryFormatPack): if InterRepository._same_model(source, target): return True @@ -3782,6 +3782,6 @@ self.target_repo.add_revision(revision_id, rev) def finished(self): - if self.target_repo._fetch_reconcile: + if self.target_repo._format._fetch_reconcile: self.target_repo.reconcile() === modified file 'bzrlib/tests/blackbox/test_push.py' --- a/bzrlib/tests/blackbox/test_push.py 2009-02-26 00:13:02 +0000 +++ b/bzrlib/tests/blackbox/test_push.py 2009-02-27 01:02:40 +0000 @@ -202,7 +202,7 @@ # being too low. If rpc_count increases, more network roundtrips have # become necessary for this use case. Please do not adjust this number # upwards without agreement from bzr's network support maintainers. - self.assertEqual(27, rpc_count) + self.assertEqual(23, rpc_count) def test_push_smart_stacked_streaming_acceptance(self): self.setup_smart_server_with_call_log() === modified file 'bzrlib/tests/branch_implementations/test_push.py' --- a/bzrlib/tests/branch_implementations/test_push.py 2009-02-25 00:31:09 +0000 +++ b/bzrlib/tests/branch_implementations/test_push.py 2009-02-27 01:02:40 +0000 @@ -419,7 +419,7 @@ self.assertEqual( ['BzrDir.open', 'BzrDir.open_branch', - 'BzrDir.find_repositoryV2', + 'BzrDir.find_repositoryV3', 'Branch.get_stacked_on_url', 'Branch.lock_write', 'Branch.last_revision_info', === modified file 'bzrlib/tests/per_repository/test_repository.py' --- a/bzrlib/tests/per_repository/test_repository.py 2009-02-24 15:11:43 +0000 +++ b/bzrlib/tests/per_repository/test_repository.py 2009-02-27 01:02:40 +0000 @@ -70,19 +70,19 @@ """Test the the _fetch_order attribute.""" tree = self.make_branch_and_tree('tree') repo = tree.branch.repository - self.assertTrue(repo._fetch_order in ('topological', 'unordered')) + self.assertTrue(repo._format._fetch_order in ('topological', 'unordered')) def test_attribute__fetch_uses_deltas(self): """Test the the _fetch_uses_deltas attribute.""" tree = self.make_branch_and_tree('tree') repo = tree.branch.repository - self.assertTrue(repo._fetch_uses_deltas in (True, False)) + self.assertTrue(repo._format._fetch_uses_deltas in (True, False)) def test_attribute__fetch_reconcile(self): """Test the the _fetch_reconcile attribute.""" tree = self.make_branch_and_tree('tree') repo = tree.branch.repository - self.assertTrue(repo._fetch_reconcile in (True, False)) + self.assertTrue(repo._format._fetch_reconcile in (True, False)) def test_attribute_inventories_store(self): """Test the existence of the inventories attribute.""" === modified file 'bzrlib/tests/test_fetch.py' --- a/bzrlib/tests/test_fetch.py 2009-01-17 01:30:58 +0000 +++ b/bzrlib/tests/test_fetch.py 2009-02-27 01:02:40 +0000 @@ -367,16 +367,16 @@ source.inventories = versionedfile.RecordingVersionedFilesDecorator( source.inventories) # precondition - self.assertTrue(target._fetch_uses_deltas) + self.assertTrue(target._format._fetch_uses_deltas) target.fetch(source, revision_id='rev-one') self.assertEqual(('get_record_stream', [('file-id', 'rev-one')], - target._fetch_order, False), + target._format._fetch_order, False), self.find_get_record_stream(source.texts.calls)) self.assertEqual(('get_record_stream', [('rev-one',)], - target._fetch_order, False), + target._format._fetch_order, False), self.find_get_record_stream(source.inventories.calls)) self.assertEqual(('get_record_stream', [('rev-one',)], - target._fetch_order, False), + target._format._fetch_order, False), self.find_get_record_stream(source.revisions.calls)) # XXX: Signatures is special, and slightly broken. The # standard item_keys_introduced_by actually does a lookup for every @@ -387,7 +387,7 @@ # we care about. signature_calls = source.signatures.calls[-1:] self.assertEqual(('get_record_stream', [('rev-one',)], - target._fetch_order, False), + target._format._fetch_order, False), self.find_get_record_stream(signature_calls)) def test_fetch_no_deltas_with_delta_closure(self): @@ -406,16 +406,21 @@ source.revisions) source.inventories = versionedfile.RecordingVersionedFilesDecorator( source.inventories) - target._fetch_uses_deltas = False + # XXX: This won't work in general, but for the dirstate format it does. + old_fetch_uses_deltas_setting = target._format._fetch_uses_deltas + def restore(): + target._format._fetch_uses_deltas = old_fetch_uses_deltas_setting + self.addCleanup(restore) + target._format._fetch_uses_deltas = False target.fetch(source, revision_id='rev-one') self.assertEqual(('get_record_stream', [('file-id', 'rev-one')], - target._fetch_order, True), + target._format._fetch_order, True), self.find_get_record_stream(source.texts.calls)) self.assertEqual(('get_record_stream', [('rev-one',)], - target._fetch_order, True), + target._format._fetch_order, True), self.find_get_record_stream(source.inventories.calls)) self.assertEqual(('get_record_stream', [('rev-one',)], - target._fetch_order, True), + target._format._fetch_order, True), self.find_get_record_stream(source.revisions.calls)) # XXX: Signatures is special, and slightly broken. The # standard item_keys_introduced_by actually does a lookup for every @@ -426,7 +431,7 @@ # we care about. signature_calls = source.signatures.calls[-1:] self.assertEqual(('get_record_stream', [('rev-one',)], - target._fetch_order, True), + target._format._fetch_order, True), self.find_get_record_stream(signature_calls)) def test_fetch_revisions_with_deltas_into_pack(self): === modified file 'bzrlib/tests/test_pack_repository.py' --- a/bzrlib/tests/test_pack_repository.py 2009-02-23 15:29:35 +0000 +++ b/bzrlib/tests/test_pack_repository.py 2009-02-27 01:02:40 +0000 @@ -73,13 +73,13 @@ """Packs do not need ordered data retrieval.""" format = self.get_format() repo = self.make_repository('.', format=format) - self.assertEqual('unordered', repo._fetch_order) + self.assertEqual('unordered', repo._format._fetch_order) def test_attribute__fetch_uses_deltas(self): """Packs reuse deltas.""" format = self.get_format() repo = self.make_repository('.', format=format) - self.assertEqual(True, repo._fetch_uses_deltas) + self.assertEqual(True, repo._format._fetch_uses_deltas) def test_disk_layout(self): format = self.get_format() === modified file 'bzrlib/tests/test_repository.py' --- a/bzrlib/tests/test_repository.py 2009-01-17 01:30:58 +0000 +++ b/bzrlib/tests/test_repository.py 2009-02-27 01:02:40 +0000 @@ -167,19 +167,19 @@ """Weaves need topological data insertion.""" control = bzrdir.BzrDirFormat6().initialize(self.get_url()) repo = weaverepo.RepositoryFormat6().initialize(control) - self.assertEqual('topological', repo._fetch_order) + self.assertEqual('topological', repo._format._fetch_order) def test_attribute__fetch_uses_deltas(self): """Weaves do not reuse deltas.""" control = bzrdir.BzrDirFormat6().initialize(self.get_url()) repo = weaverepo.RepositoryFormat6().initialize(control) - self.assertEqual(False, repo._fetch_uses_deltas) + self.assertEqual(False, repo._format._fetch_uses_deltas) def test_attribute__fetch_reconcile(self): """Weave repositories need a reconcile after fetch.""" control = bzrdir.BzrDirFormat6().initialize(self.get_url()) repo = weaverepo.RepositoryFormat6().initialize(control) - self.assertEqual(True, repo._fetch_reconcile) + self.assertEqual(True, repo._format._fetch_reconcile) def test_no_ancestry_weave(self): control = bzrdir.BzrDirFormat6().initialize(self.get_url()) @@ -202,19 +202,19 @@ """Weaves need topological data insertion.""" control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) repo = weaverepo.RepositoryFormat7().initialize(control) - self.assertEqual('topological', repo._fetch_order) + self.assertEqual('topological', repo._format._fetch_order) def test_attribute__fetch_uses_deltas(self): """Weaves do not reuse deltas.""" control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) repo = weaverepo.RepositoryFormat7().initialize(control) - self.assertEqual(False, repo._fetch_uses_deltas) + self.assertEqual(False, repo._format._fetch_uses_deltas) def test_attribute__fetch_reconcile(self): """Weave repositories need a reconcile after fetch.""" control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) repo = weaverepo.RepositoryFormat7().initialize(control) - self.assertEqual(True, repo._fetch_reconcile) + self.assertEqual(True, repo._format._fetch_reconcile) def test_disk_layout(self): control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) @@ -348,13 +348,13 @@ """Knits need topological data insertion.""" repo = self.make_repository('.', format=bzrdir.format_registry.get('knit')()) - self.assertEqual('topological', repo._fetch_order) + self.assertEqual('topological', repo._format._fetch_order) def test_attribute__fetch_uses_deltas(self): """Knits reuse deltas.""" repo = self.make_repository('.', format=bzrdir.format_registry.get('knit')()) - self.assertEqual(True, repo._fetch_uses_deltas) + self.assertEqual(True, repo._format._fetch_uses_deltas) def test_disk_layout(self): control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) @@ -619,14 +619,14 @@ format = bzrdir.BzrDirMetaFormat1() format.repository_format = knitrepo.RepositoryFormatKnit3() repo = self.make_repository('.', format=format) - self.assertEqual('topological', repo._fetch_order) + self.assertEqual('topological', repo._format._fetch_order) def test_attribute__fetch_uses_deltas(self): """Knits reuse deltas.""" format = bzrdir.BzrDirMetaFormat1() format.repository_format = knitrepo.RepositoryFormatKnit3() repo = self.make_repository('.', format=format) - self.assertEqual(True, repo._fetch_uses_deltas) + self.assertEqual(True, repo._format._fetch_uses_deltas) def test_convert(self): """Ensure the upgrade adds weaves for roots""" === modified file 'bzrlib/tests/test_smart.py' --- a/bzrlib/tests/test_smart.py 2009-02-23 15:29:35 +0000 +++ b/bzrlib/tests/test_smart.py 2009-02-27 01:02:40 +0000 @@ -65,6 +65,8 @@ "_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV1}), ("find_repositoryV2", { "_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV2}), + ("find_repositoryV3", { + "_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV3}), ] to_adapt, result = split_suite_by_re(standard_tests, "TestSmartServerRequestFindRepository") @@ -214,7 +216,12 @@ subtrees = 'yes' else: subtrees = 'no' - if (smart.bzrdir.SmartServerRequestFindRepositoryV2 == + if (smart.bzrdir.SmartServerRequestFindRepositoryV3 == + self._request_class): + return SuccessfulSmartServerResponse( + ('ok', '', rich_root, subtrees, 'no', + repo._format.network_name())) + elif (smart.bzrdir.SmartServerRequestFindRepositoryV2 == self._request_class): # All tests so far are on formats, and for non-external # repositories. -- bazaar-commits mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/bazaar-commits
