Rev 4020: Add effort test for init-repo on smart server urls. in http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips
Robert Collins
robertc at robertcollins.net
Thu Feb 19 03:35:50 GMT 2009
At http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips
------------------------------------------------------------
revno: 4020
revision-id: robertc at robertcollins.net-20090219033543-s63jjuz9vcgrnio9
parent: robertc at robertcollins.net-20090219020654-1l19ged3zo7212jh
parent: robertc at robertcollins.net-20090219030955-1gqi3hfhg3h16eqv
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Thu 2009-02-19 14:35:43 +1100
message:
Add effort test for init-repo on smart server urls.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/blackbox/test_shared_repository.py test_shared_repository.py-20060317053531-ed30c0d79325e483
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
------------------------------------------------------------
revno: 3990.5.3
revision-id: robertc at robertcollins.net-20090219030955-1gqi3hfhg3h16eqv
parent: robertc at robertcollins.net-20090218210002-0lnnxjxmrnoj8qdk
committer: Robert Collins <robertc at robertcollins.net>
branch nick: network-name
timestamp: Thu 2009-02-19 14:09:55 +1100
message:
Docs and polish on RepositoryFormat.network_name.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
------------------------------------------------------------
revno: 3990.5.2
revision-id: robertc at robertcollins.net-20090218210002-0lnnxjxmrnoj8qdk
parent: andrew.bennetts at canonical.com-20090210054404-tej9hra1kpom9fc2
parent: pqm at pqm.ubuntu.com-20090218132708-okubrahz9exvae9r
committer: Robert Collins <robertc at robertcollins.net>
branch nick: network-name
timestamp: Thu 2009-02-19 08:00:02 +1100
message:
Merge bzr.dev.
added:
bzrlib/help_topics/en/log-formats.txt logformats.txt-20090209081655-5wpbws2oqz8k5oq7-1
bzrlib/plugins/launchpad/test_lp_open.py test_lp_open.py-20090125174355-hxrsxh3sj84225qu-1
bzrlib/tests/test_smart_request.py test_smart_request.p-20090211070731-o38wayv3asm25d6a-1
doc/developers/colocated-branches.txt colocatedbranches.tx-20090209183539-wv9upczfd8ryyfn1-1
tools/prepare_for_latex.py prepare_for_latex.py-20090212165735-79tn1t4dhnxyz7m9-1
tools/rst2pdf.py rst2pdf.py-20090212165735-79tn1t4dhnxyz7m9-2
modified:
.bzrignore bzrignore-20050311232317-81f7b71efa2db11a
Makefile Makefile-20050805140406-d96e3498bb61c5bb
NEWS NEWS-20050323055033-4e00b5db738777ff
bzr bzr.py-20050313053754-5485f144c7006fa6
bzrlib/__init__.py __init__.py-20050309040759-33e65acf91bbcd5d
bzrlib/_dirstate_helpers_c.pyx dirstate_helpers.pyx-20070503201057-u425eni465q4idwn-3
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bundle/__init__.py changeset.py-20050513021216-b02ab57fb9738913
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
bzrlib/help_topics/en/configuration.txt configuration.txt-20060314161707-868350809502af01
bzrlib/help_topics/en/hooks.txt hooks.txt-20070830033044-xxu2rced13f72dka-1
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/missing.py missing.py-20050812153334-097f7097e2a8bcd1
bzrlib/msgeditor.py msgeditor.py-20050901111708-ef6d8de98f5d8f2f
bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
bzrlib/plugins/launchpad/lp_registration.py lp_registration.py-20060315190948-daa617eafe3a8d48
bzrlib/plugins/launchpad/test_lp_directory.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
bzrlib/plugins/launchpad/test_lp_service.py test_lp_service.py-20080213034527-drf0ucr2x1js3onb-1
bzrlib/reconfigure.py reconfigure.py-20070908040425-6ykgo7escxhyrg9p-1
bzrlib/registry.py lazy_factory.py-20060809213415-2gfvqadtvdn0phtg-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
bzrlib/smart/branch.py branch.py-20061124031907-mzh3pla28r83r97f-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/status.py status.py-20050505062338-431bfa63ec9b19e6
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/blackbox/test_reconfigure.py test_reconfigure.py-20070908173426-khfo5fi2rgzgtwj3-1
bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
bzrlib/tests/branch_implementations/test_hooks.py test_hooks.py-20070129154855-blhpwxmvjs07waei-1
bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
bzrlib/tests/per_repository/test_add_fallback_repository.py test_add_fallback_re-20080215040003-8w9n4ck9uqdxj18m-1
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_commands.py test_command.py-20051019190109-3b17be0f52eaa7a8
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_http.py testhttp.py-20051018020158-b2eef6e867c514d9
bzrlib/tests/test_info.py test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
bzrlib/tests/test_msgeditor.py test_msgeditor.py-20051202041359-920315ec6011ee51
bzrlib/tests/test_read_bundle.py test_read_bundle.py-20060615211421-ud8cwr1ulgd914zf-1
bzrlib/tests/test_reconfigure.py test_reconfigure.py-20070908040425-6ykgo7escxhyrg9p-2
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
bzrlib/tests/test_shelf_ui.py test_shelf_ui.py-20081027155203-wtcuazg85wp9u4fv-1
bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
bzrlib/tests/test_status.py test_status.py-20060516190614-fbf6432e4a6e8aa5
bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
bzrlib/trace.py trace.py-20050309040759-c8ed824bdcd4748a
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
bzrlib/transport/remote.py ssh.py-20060608202016-c25gvf1ob7ypbus6-1
bzrlib/win32utils.py win32console.py-20051021033308-123c6c929d04973d
doc/developers/HACKING.txt HACKING-20050805200004-2a5dc975d870f78c
doc/developers/index.txt index.txt-20070508041241-qznziunkg0nffhiw-1
doc/developers/ppa.txt ppa.txt-20080722055539-606u7t2z32t3ae4w-1
doc/developers/releasing.txt releasing.txt-20080502015919-fnrcav8fwy8ccibu-1
setup.py setup.py-20050314065409-02f8a0a6e3f9bc70
tools/packaging/build-packages.sh buildpackages.sh-20080821102059-fzlodktas65qmo1k-1
tools/packaging/update-changelogs.sh updatechangelogs.sh-20080821102059-fzlodktas65qmo1k-2
tools/packaging/update-packaging-branches.sh updatepackagingbranc-20080825210254-6is8ciit1yzyd3a2-1
tools/win32/build_release.py build_release.py-20081105204355-2ghh5cv01v1x4rzz-1
tools/win32/bzr.iss.cog bzr.iss.cog-20060622100836-b3yup582rt3y0nvm-5
------------------------------------------------------------
revno: 3990.5.1
revision-id: andrew.bennetts at canonical.com-20090210054404-tej9hra1kpom9fc2
parent: pqm at pqm.ubuntu.com-20090209210810-cq9lgqy519b7wfyi
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: RepoFormat network name
timestamp: Tue 2009-02-10 16:44:04 +1100
message:
Add network_name() to RepositoryFormat.
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
=== modified file 'NEWS'
--- a/NEWS 2009-02-18 12:48:23 +0000
+++ b/NEWS 2009-02-19 03:09:55 +0000
@@ -69,6 +69,9 @@
command object before the command is run (or help generated from
it), without overriding the command. (Robert Collins)
+ * ``RepositoryFormat`` objects now have a ``network_name`` for passing
+ the format across RPC calls. (Robert Collins, Andrew Bennetts)
+
* Some methods have been pulled up from ``BzrBranch`` to ``Branch``
to aid branch types that are not bzr branch objects (like
RemoteBranch). (Robert Collins, Andrew Bennetts)
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2009-02-19 02:06:54 +0000
+++ b/bzrlib/bzrdir.py 2009-02-19 03:35:43 +0000
@@ -3091,6 +3091,9 @@
# appear in chronological order and format descriptions can build
# on previous ones.
format_registry = BzrDirFormatRegistry()
+# The pre-0.8 formats have their repository format network name registered in
+# repository.py. MetaDir formats have their repository format network name
+# inferred from their disk format string.
format_registry.register('weave', BzrDirFormat6,
'Pre-0.8 format. Slower than knit and does not'
' support checkouts or shared repositories.',
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2009-02-13 00:52:18 +0000
+++ b/bzrlib/remote.py 2009-02-19 03:09:55 +0000
@@ -205,7 +205,9 @@
format.supports_external_lookups = (response[4] == 'yes')
# Used to support creating a real format instance when needed.
format._creating_bzrdir = self
- return RemoteRepository(self, format)
+ remote_repo = RemoteRepository(self, format)
+ format._creating_repo = remote_repo
+ return remote_repo
else:
raise errors.NoRepositoryPresent(self)
@@ -265,6 +267,13 @@
the attributes rich_root_data and supports_tree_reference are set
on a per instance basis, and are not set (and should not be) at
the class level.
+
+ :ivar _custom_format: If set, a specific concrete repository format that
+ will be used when initializing a repository with this
+ RemoteRepositoryFormat.
+ :ivar _creating_repo: If set, the repository object that this
+ RemoteRepositoryFormat was created for: it can be called into
+ to obtain data like te network name.
"""
_matchingbzrdir = RemoteBzrDirFormat()
@@ -312,6 +321,10 @@
raise errors.BadConversionTarget(
'Does not support nested trees', target_format)
+ def network_name(self):
+ self._creating_repo._ensure_real()
+ return self._creating_repo._real_repository._format.network_name()
+
class RemoteRepository(_RpcHelper):
"""Repository accessed over rpc.
=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py 2008-11-21 02:52:32 +0000
+++ b/bzrlib/repofmt/weaverepo.py 2009-02-19 03:09:55 +0000
@@ -399,6 +399,10 @@
def get_format_description(self):
"""See RepositoryFormat.get_format_description()."""
return "Weave repository format 5"
+
+ def network_name(self):
+ """The network name for this format is the control dirs disk label."""
+ return self._matchingbzrdir.get_format_string()
def _get_inventories(self, repo_transport, repo, name='inventory'):
mapper = versionedfile.ConstantMapper(name)
@@ -444,6 +448,10 @@
"""See RepositoryFormat.get_format_description()."""
return "Weave repository format 6"
+ def network_name(self):
+ """The network name for this format is the control dirs disk label."""
+ return self._matchingbzrdir.get_format_string()
+
def _get_inventories(self, repo_transport, repo, name='inventory'):
mapper = versionedfile.ConstantMapper(name)
return versionedfile.ThunkedVersionedFiles(repo_transport,
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2009-01-27 07:48:55 +0000
+++ b/bzrlib/repository.py 2009-02-19 03:09:55 +0000
@@ -2191,6 +2191,21 @@
class RepositoryFormatRegistry(registry.Registry):
"""Registry of RepositoryFormats."""
+ def __init__(self, other_registry=None):
+ registry.Registry.__init__(self)
+ self._other_registry = other_registry
+
+ def register_lazy(self, key, module_name, member_name,
+ help=None, info=None,
+ override_existing=False):
+ # Overridden to allow capturing registrations to two seperate
+ # registries in a single call.
+ registry.Registry.register_lazy(self, key, module_name, member_name,
+ help=help, info=info, override_existing=override_existing)
+ if self._other_registry is not None:
+ self._other_registry.register_lazy(key, module_name, member_name,
+ help=help, info=info, override_existing=override_existing)
+
def get(self, format_string):
r = registry.Registry.get(self, format_string)
if callable(r):
@@ -2198,8 +2213,17 @@
return r
-format_registry = RepositoryFormatRegistry()
-"""Registry of formats, indexed by their identifying format string.
+network_format_registry = RepositoryFormatRegistry()
+"""Registry of formats indexed by their network name.
+
+The network name for a repository format is an identifier that can be used when
+referring to formats with smart server operations. See
+RepositoryFormat.network_name() for more detail.
+"""
+
+
+format_registry = RepositoryFormatRegistry(network_format_registry)
+"""Registry of formats, indexed by their BzrDirMetaFormat format string.
This can contain either format instances themselves, or classes/factories that
can be called to obtain one.
@@ -2212,24 +2236,27 @@
class RepositoryFormat(object):
"""A repository format.
- Formats provide three things:
+ Formats provide four things:
* An initialization routine to construct repository data on disk.
- * a format string which is used when the BzrDir supports versioned
- children.
+ * a optional format string which is used when the BzrDir supports
+ versioned children.
* an open routine which returns a Repository instance.
+ * A network name for referring to the format in smart server RPC
+ methods.
There is one and only one Format subclass for each on-disk format. But
there can be one Repository subclass that is used for several different
formats. The _format attribute on a Repository instance can be used to
determine the disk format.
- Formats are placed in an dict by their format string for reference
- during opening. These should be subclasses of RepositoryFormat
- for consistency.
+ Formats are placed in a registry by their format string for reference
+ during opening. These should be subclasses of RepositoryFormat for
+ consistency.
Once a format is deprecated, just deprecate the initialize and open
methods on the format class. Do not deprecate the object, as the
- object will be created every system load.
+ object may be created even when a repository instnace hasn't been
+ created.
Common instance attributes:
_matchingbzrdir - the bzrdir format that the repository format was
@@ -2342,6 +2369,16 @@
"""
return True
+ def network_name(self):
+ """A simple byte string uniquely identifying this format for RPC calls.
+
+ MetaDir repository formats use their disk format string to identify the
+ repository over the wire. All in one formats such as bzr < 0.8, and
+ foreign formats like svn/git and hg should use some marker which is
+ unique and immutable.
+ """
+ raise NotImplementedError(self.network_name)
+
def check_conversion_target(self, target_format):
raise NotImplementedError(self.check_conversion_target)
@@ -2397,9 +2434,28 @@
finally:
control_files.unlock()
-
-# formats which have no format string are not discoverable
-# and not independently creatable, so are not registered. They're
+ def network_name(self):
+ """Metadir formats have matching disk and network format strings."""
+ return self.get_format_string()
+
+
+# Pre-0.8 formats that don't have a disk format string (because they are
+# versioned by the matching control directory). We use the control directories
+# disk format string as a key for the network_name because they meet the
+# constraints (simple string, unique, immmutable).
+network_format_registry.register_lazy(
+ "Bazaar-NG branch, format 5\n",
+ 'bzrlib.repofmt.weaverepo',
+ 'RepositoryFormat5',
+)
+network_format_registry.register_lazy(
+ "Bazaar-NG branch, format 6\n",
+ 'bzrlib.repofmt.weaverepo',
+ 'RepositoryFormat6',
+)
+
+# formats which have no format string are not discoverable or independently
+# creatable on disk, so are not registered in format_registry. They're
# all in bzrlib.repofmt.weaverepo now. When an instance of one of these is
# needed, it's constructed directly by the BzrDir. Non-native formats where
# the repository is not separately opened are similar.
=== modified file 'bzrlib/tests/blackbox/test_shared_repository.py'
--- a/bzrlib/tests/blackbox/test_shared_repository.py 2008-07-18 07:29:06 +0000
+++ b/bzrlib/tests/blackbox/test_shared_repository.py 2009-02-19 03:35:43 +0000
@@ -108,3 +108,16 @@
self.run_bzr("init-repo --no-trees notrees")
repo = BzrDir.open("notrees").open_repository()
self.assertEqual(False, repo.make_working_trees())
+
+ def test_init_repo_smart_acceptance(self):
+ # The amount of hpss calls made on init-repo to a smart server should
+ # be fixed.
+ self.setup_smart_server_with_call_log()
+ self.run_bzr(['init-repo', self.get_url('repo')])
+ rpc_count = len(self.hpss_calls)
+ # This figure represent the amount of work to perform this use case. It
+ # is entirely ok to reduce this number if a test fails due to rpc_count
+ # 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(40, rpc_count)
=== modified file 'bzrlib/tests/per_repository/test_repository.py'
--- a/bzrlib/tests/per_repository/test_repository.py 2009-02-13 00:52:18 +0000
+++ b/bzrlib/tests/per_repository/test_repository.py 2009-02-18 21:00:02 +0000
@@ -298,6 +298,26 @@
self.assertEqual(self.repository_format,
self.bzrdir_format.repository_format)
+ def test_format_network_name(self):
+ repo = self.make_repository('r')
+ format = repo._format
+ network_name = format.network_name()
+ self.assertIsInstance(network_name, str)
+ # We want to test that the network_name matches the actual format on
+ # disk. For local repositories, that means that using network_name as
+ # a key in the registry gives back the same format. For remote
+ # repositories, that means that the network_name of the
+ # RemoteRepositoryFormat we have locally matches the actual format
+ # present on the remote side.
+ if isinstance(format, remote.RemoteRepositoryFormat):
+ repo._ensure_real()
+ real_repo = repo._real_repository
+ self.assertEqual(real_repo._format.network_name(), network_name)
+ else:
+ registry = repository.network_format_registry
+ looked_up_format = registry.get(network_name)
+ self.assertEqual(format.__class__, looked_up_format.__class__)
+
def test_create_repository(self):
# bzrdir can construct a repository for itself.
if not self.bzrdir_format.is_supported():
More information about the bazaar-commits
mailing list