Rev 3228: Add external references support attribute to repository formats. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Feb 20 01:40:19 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3228
revision-id:pqm at pqm.ubuntu.com-20080220014008-9appc9kw4rjg8v1k
parent: pqm at pqm.ubuntu.com-20080219222102-rqz9oxck1qbibvkm
parent: robertc at robertcollins.net-20080219041134-03amd7siou1c8ugw
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-02-20 01:40:08 +0000
message:
Add external references support attribute to repository formats.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/smart/bzrdir.py bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
------------------------------------------------------------
revno: 3221.3.5
revision-id:robertc at robertcollins.net-20080219041134-03amd7siou1c8ugw
parent: robertc at robertcollins.net-20080219035832-lyyksopcl80ncwes
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository-stackable-flag
timestamp: Tue 2008-02-19 15:11:34 +1100
message:
Relocate NEWS entries to 1.3.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 3221.3.4
revision-id:robertc at robertcollins.net-20080219035832-lyyksopcl80ncwes
parent: robertc at robertcollins.net-20080212051725-m8fjb5ouzl1pkso0
parent: pqm at pqm.ubuntu.com-20080219014045-w3igijttjdcpwshz
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository-stackable-flag
timestamp: Tue 2008-02-19 14:58:32 +1100
message:
Integrate bzr.dev.
added:
doc/developers/development-repo.txt developmentrepo.txt-20080102200205-raj42k61dch8pjmj-1
modified:
.bzrignore bzrignore-20050311232317-81f7b71efa2db11a
NEWS NEWS-20050323055033-4e00b5db738777ff
bzr bzr.py-20050313053754-5485f144c7006fa6
bzrlib/__init__.py __init__.py-20050309040759-33e65acf91bbcd5d
bzrlib/bundle/commands.py __init__.py-20050617152058-1b6530d9ab85c11c
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/info.py info.py-20050323235939-6bbfe7d9700b0b9b
bzrlib/progress.py progress.py-20050610070202-df9faaab791964c0
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/symbol_versioning.py symbol_versioning.py-20060105104851-9ecf8af605d15a80
bzrlib/tests/blackbox/test_bundle_info.py test_bundle_info.py-20070816181255-eiuodwxuqu7w7gxf-1
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_info.py test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
bzrlib/tests/test_progress.py test_progress.py-20060308160359-978c397bc79b7fda
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
bzrlib/tests/test_workingtree_4.py test_workingtree_4.p-20070223025758-531n3tznl3zacv2o-1
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
------------------------------------------------------------
revno: 3221.3.3
revision-id:robertc at robertcollins.net-20080212051725-m8fjb5ouzl1pkso0
parent: robertc at robertcollins.net-20080212045218-2yo8xf84u7458320
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository-stackable-flag
timestamp: Tue 2008-02-12 16:17:25 +1100
message:
* Hook up the new remote method ``RemoteBzrDir.find_repositoryV2`` so
that it is now attempted first when lookup up repositories, leading to
an extra round trip on older bzr smart servers but supporting the
feature on newer servers. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/smart/bzrdir.py bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 3221.3.2
revision-id:robertc at robertcollins.net-20080212045218-2yo8xf84u7458320
parent: robertc at robertcollins.net-20080212023827-019lghqbrm3tukgl
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository-stackable-flag
timestamp: Tue 2008-02-12 15:52:18 +1100
message:
* New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for
detecting external lookup support on remote repositories.
(Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/smart/bzrdir.py bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
------------------------------------------------------------
revno: 3221.3.1
revision-id:robertc at robertcollins.net-20080212023827-019lghqbrm3tukgl
parent: pqm at pqm.ubuntu.com-20080208064756-bg0zu0y4e789j50r
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository-stackable-flag
timestamp: Tue 2008-02-12 13:38:27 +1100
message:
* Repository formats have a new supported-feature attribute
``supports_external_lookups`` used to indicate repositories which support
falling back to other repositories when they have partial data.
(Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
=== modified file 'NEWS'
--- a/NEWS 2008-02-19 22:21:02 +0000
+++ b/NEWS 2008-02-20 01:40:08 +0000
@@ -32,6 +32,16 @@
INTERNALS:
+ * New remote method ``RemoteBzrDir.find_repositoryV2`` adding support for
+ detecting external lookup support on remote repositories. This method is
+ now attempted first when lookup up repositories, leading to an extra
+ round trip on older bzr smart servers. (Robert Collins)
+
+ * Repository formats have a new supported-feature attribute
+ ``supports_external_lookups`` used to indicate repositories which support
+ falling back to other repositories when they have partial data.
+ (Robert Collins)
+
* The bzrdir format registry now accepts an ``alias`` keyword to
register_metadir, used to indicate that a format name is an alias for
some other format and thus should not be reported when describing the
@@ -204,7 +214,7 @@
which will split out ghosts and present parents into two separate sets,
useful for code which needs to be aware of ghosts (e.g. fetching data
cares about ghosts during revision selection). (Robert Collins)
-
+
* Record a timestamp against each mutter to the trace file, relative to the
first import of bzrlib. (Andrew Bennetts)
@@ -215,14 +225,14 @@
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``,
removing one round trip on many network operations. (Robert Collins)
+ * RemoteTransport's ``recommended_page_size`` method now returns 64k, like
+ SFTPTransport and HttpTransportBase. (Andrew Bennetts)
+
* Repository has a new method ``has_revisions`` which signals the presence
of many revisions by returning a set of the revisions listed which are
present. This can be done by index queries without reading data for parent
revision names etc. (Robert Collins)
- * RemoteTransport's ``recommended_page_size`` method now returns 64k, like
- SFTPTransport and HttpTransportBase. (Andrew Bennetts)
-
bzr 1.1 2008-01-15
------------------
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-02-07 03:47:24 +0000
+++ b/bzrlib/remote.py 2008-02-12 05:17:25 +0000
@@ -148,16 +148,29 @@
def open_repository(self):
path = self._path_for_remote_call(self._client)
- response = self._client.call('BzrDir.find_repository', path)
+ verb = 'BzrDir.find_repositoryV2'
+ response = self._client.call(verb, path)
+ if (response == ('error', "Generic bzr smart protocol error: "
+ "bad request '%s'" % verb) or
+ response == ('error', "Generic bzr smart protocol error: "
+ "bad request u'%s'" % verb)):
+ verb = 'BzrDir.find_repository'
+ response = self._client.call(verb, path)
assert response[0] in ('ok', 'norepository'), \
'unexpected response code %s' % (response,)
if response[0] == 'norepository':
raise errors.NoRepositoryPresent(self)
- assert len(response) == 4, 'incorrect response length %s' % (response,)
+ if verb == 'BzrDir.find_repository':
+ # servers that don't support the V2 method don't support external
+ # references either.
+ response = response + ('no', )
+ assert len(response) == 5, 'incorrect response length %s' % (response,)
if response[1] == '':
format = RemoteRepositoryFormat()
format.rich_root_data = (response[2] == 'yes')
format.supports_tree_reference = (response[3] == 'yes')
+ # No wire format to check this yet.
+ format.supports_external_lookups = (response[4] == 'yes')
return RemoteRepository(self, format)
else:
raise errors.NoRepositoryPresent(self)
@@ -284,6 +297,9 @@
self._reconcile_fixes_text_parents = False
self._reconcile_backsup_inventory = False
self.base = self.bzrdir.transport.base
+ # Can this repository be given external locations to lookup additional
+ # data.
+ self.supports_external_lookups = False
def __str__(self):
return "%s(%s)" % (self.__class__.__name__, self.base)
=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py 2008-01-17 05:30:53 +0000
+++ b/bzrlib/repofmt/knitrepo.py 2008-02-12 02:38:27 +0000
@@ -354,6 +354,8 @@
_serializer = xml5.serializer_v5
# Knit based repositories handle ghosts reasonably well.
supports_ghosts = True
+ # External lookups are not supported in this format.
+ supports_external_lookups = False
def _get_control_store(self, repo_transport, control_files):
"""Return the control store for this repository."""
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py 2008-02-13 22:11:40 +0000
+++ b/bzrlib/repofmt/pack_repo.py 2008-02-19 03:58:32 +0000
@@ -2055,6 +2055,8 @@
# Set this attribute in derived clases to control the _serializer that the
# repository objects will have passed to their constructor.
_serializer = None
+ # External references are not supported in pack repositories yet.
+ supports_external_lookups = False
def _get_control_store(self, repo_transport, control_files):
"""Return the control store for this repository."""
=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py 2008-01-11 03:54:51 +0000
+++ b/bzrlib/repofmt/weaverepo.py 2008-02-12 02:38:27 +0000
@@ -338,6 +338,7 @@
rich_root_data = False
supports_tree_reference = False
supports_ghosts = False
+ supports_external_lookups = False
def initialize(self, a_bzrdir, shared=False, _internal=False):
"""Create a weave repository."""
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2008-02-13 22:11:40 +0000
+++ b/bzrlib/repository.py 2008-02-19 03:58:32 +0000
@@ -2090,6 +2090,9 @@
# Set to True or False in derived classes. True indicates that the format
# supports ghosts gracefully.
supports_ghosts = None
+ # Can this repository be given external locations to lookup additional
+ # data. Set to True or False in derived classes.
+ supports_external_lookups = None
def __str__(self):
return "<%s>" % self.__class__.__name__
@@ -2234,6 +2237,7 @@
rich_root_data = False
supports_tree_reference = False
+ supports_external_lookups = False
_matchingbzrdir = bzrdir.BzrDirMetaFormat1()
def __init__(self):
=== modified file 'bzrlib/smart/bzrdir.py'
--- a/bzrlib/smart/bzrdir.py 2007-04-24 12:20:09 +0000
+++ b/bzrlib/smart/bzrdir.py 2008-02-12 05:17:25 +0000
@@ -44,35 +44,83 @@
class SmartServerRequestFindRepository(SmartServerRequest):
- def do(self, path):
+ def _boolean_to_yes_no(self, a_boolean):
+ if a_boolean:
+ return 'yes'
+ else:
+ return 'no'
+
+ def _find(self, path):
"""try to find a repository from path upwards
This operates precisely like 'bzrdir.find_repository'.
- If a bzrdir is not present, an exception is propogated
- rather than 'no branch' because these are different conditions.
-
- :return: norepository or ok, relpath.
+ :return: (relpath, rich_root, tree_ref, external_lookup) flags. All are
+ strings, relpath is a / prefixed path, and the other three are
+ either 'yes' or 'no'.
+ :raises errors.NoRepositoryPresent: When there is no repository
+ present.
"""
bzrdir = BzrDir.open_from_transport(self._backing_transport.clone(path))
- try:
- repository = bzrdir.find_repository()
- # the relpath of the bzrdir in the found repository gives us the
- # path segments to pop-out.
- relpath = repository.bzrdir.root_transport.relpath(bzrdir.root_transport.base)
- if len(relpath):
- segments = ['..'] * len(relpath.split('/'))
- else:
- segments = []
- if repository.supports_rich_root():
- rich_root = 'yes'
- else:
- rich_root = 'no'
- if repository._format.supports_tree_reference:
- tree_ref = 'yes'
- else:
- tree_ref = 'no'
- return SuccessfulSmartServerResponse(('ok', '/'.join(segments), rich_root, tree_ref))
+ repository = bzrdir.find_repository()
+ # the relpath of the bzrdir in the found repository gives us the
+ # path segments to pop-out.
+ relpath = repository.bzrdir.root_transport.relpath(bzrdir.root_transport.base)
+ if len(relpath):
+ segments = ['..'] * len(relpath.split('/'))
+ else:
+ segments = []
+ rich_root = self._boolean_to_yes_no(repository.supports_rich_root())
+ tree_ref = self._boolean_to_yes_no(
+ repository._format.supports_tree_reference)
+ external_lookup = self._boolean_to_yes_no(
+ repository._format.supports_external_lookups)
+ return '/'.join(segments), rich_root, tree_ref, external_lookup
+
+
+class SmartServerRequestFindRepositoryV1(SmartServerRequestFindRepository):
+
+ def do(self, path):
+ """try to find a repository from path upwards
+
+ This operates precisely like 'bzrdir.find_repository'.
+
+ If a bzrdir is not present, an exception is propogated
+ rather than 'no branch' because these are different conditions.
+
+ This is the initial version of this method introduced with the smart
+ server. Modern clients will try the V2 method that adds support for the
+ supports_external_lookups attribute.
+
+ :return: norepository or ok, relpath.
+ """
+ try:
+ path, rich_root, tree_ref, external_lookup = self._find(path)
+ return SuccessfulSmartServerResponse(('ok', path, rich_root, tree_ref))
+ except errors.NoRepositoryPresent:
+ return FailedSmartServerResponse(('norepository', ))
+
+
+class SmartServerRequestFindRepositoryV2(SmartServerRequestFindRepository):
+
+ def do(self, path):
+ """try to find a repository from path upwards
+
+ This operates precisely like 'bzrdir.find_repository'.
+
+ If a bzrdir is not present, an exception is propogated
+ rather than 'no branch' because these are different conditions.
+
+ This is the second edition of this method introduced in bzr 1.3, which
+ returns information about the supports_external_lookups format
+ attribute too.
+
+ :return: norepository or ok, relpath.
+ """
+ try:
+ path, rich_root, tree_ref, external_lookup = self._find(path)
+ return SuccessfulSmartServerResponse(
+ ('ok', path, rich_root, tree_ref, external_lookup))
except errors.NoRepositoryPresent:
return FailedSmartServerResponse(('norepository', ))
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py 2008-01-17 07:47:52 +0000
+++ b/bzrlib/smart/request.py 2008-02-12 04:52:18 +0000
@@ -286,7 +286,9 @@
request_handlers.register_lazy(
'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
request_handlers.register_lazy(
- 'BzrDir.find_repository', 'bzrlib.smart.bzrdir', 'SmartServerRequestFindRepository')
+ 'BzrDir.find_repository', 'bzrlib.smart.bzrdir', 'SmartServerRequestFindRepositoryV1')
+request_handlers.register_lazy(
+ 'BzrDir.find_repositoryV2', 'bzrlib.smart.bzrdir', 'SmartServerRequestFindRepositoryV2')
request_handlers.register_lazy(
'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir', 'SmartServerRequestInitializeBzrDir')
request_handlers.register_lazy(
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py 2008-02-06 00:06:53 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py 2008-02-12 02:38:27 +0000
@@ -267,6 +267,11 @@
text = repo._format.get_format_description()
self.failUnless(len(text))
+ def test_format_supports_external_lookups(self):
+ repo = self.make_repository('.')
+ self.assertSubset(
+ [repo._format.supports_external_lookups], (True, False))
+
def assertMessageRoundtrips(self, message):
"""Assert that message roundtrips to a repository and back intact."""
tree = self.make_branch_and_tree('.')
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2008-02-07 03:47:24 +0000
+++ b/bzrlib/tests/test_remote.py 2008-02-12 05:17:25 +0000
@@ -197,13 +197,13 @@
transport = MemoryTransport()
transport.mkdir('quack')
transport = transport.clone('quack')
- client = FakeClient([(('ok', ''), ), (('ok', '', 'no', 'no'), )],
+ client = FakeClient([(('ok', ''), ), (('ok', '', 'no', 'no', 'no'), )],
transport.base)
bzrdir = RemoteBzrDir(transport, _client=client)
result = bzrdir.open_branch()
self.assertEqual(
[('call', 'BzrDir.open_branch', ('quack/',)),
- ('call', 'BzrDir.find_repository', ('quack/',))],
+ ('call', 'BzrDir.find_repositoryV2', ('quack/',))],
client._calls)
self.assertIsInstance(result, RemoteBranch)
self.assertEqual(bzrdir, result.bzrdir)
@@ -240,16 +240,16 @@
# Relpaths on the wire should not be URL-escaped. So "~" should be
# transmitted as "~", not "%7E".
transport = RemoteTransport('bzr://localhost/~hello/')
- client = FakeClient([(('ok', ''), ), (('ok', '', 'no', 'no'), )],
+ client = FakeClient([(('ok', ''), ), (('ok', '', 'no', 'no', 'no'), )],
transport.base)
bzrdir = RemoteBzrDir(transport, _client=client)
result = bzrdir.open_branch()
self.assertEqual(
[('call', 'BzrDir.open_branch', ('~hello/',)),
- ('call', 'BzrDir.find_repository', ('~hello/',))],
+ ('call', 'BzrDir.find_repositoryV2', ('~hello/',))],
client._calls)
- def check_open_repository(self, rich_root, subtrees):
+ def check_open_repository(self, rich_root, subtrees, external_lookup='no'):
transport = MemoryTransport()
transport.mkdir('quack')
transport = transport.clone('quack')
@@ -261,12 +261,13 @@
subtree_response = 'yes'
else:
subtree_response = 'no'
- client = FakeClient([(('ok', '', rich_response, subtree_response), ),],
- transport.base)
+ client = FakeClient(
+ [(('ok', '', rich_response, subtree_response, external_lookup), ),],
+ transport.base)
bzrdir = RemoteBzrDir(transport, _client=client)
result = bzrdir.open_repository()
self.assertEqual(
- [('call', 'BzrDir.find_repository', ('quack/',))],
+ [('call', 'BzrDir.find_repositoryV2', ('quack/',))],
client._calls)
self.assertIsInstance(result, RemoteRepository)
self.assertEqual(bzrdir, result.bzrdir)
@@ -278,6 +279,7 @@
self.check_open_repository(False, True)
self.check_open_repository(True, False)
self.check_open_repository(False, False)
+ self.check_open_repository(False, False, 'yes')
def test_old_server(self):
"""RemoteBzrDirFormat should fail to probe if the server version is too
=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py 2008-02-13 22:11:40 +0000
+++ b/bzrlib/tests/test_repository.py 2008-02-19 03:58:32 +0000
@@ -176,6 +176,11 @@
self.assertRaises(errors.OutSideTransaction,
inv.add_lines, 'foo', [], [])
+ def test_supports_external_lookups(self):
+ control = bzrdir.BzrDirFormat6().initialize(self.get_url())
+ repo = weaverepo.RepositoryFormat6().initialize(control)
+ self.assertFalse(repo._format.supports_external_lookups)
+
class TestFormat7(TestCaseWithTransport):
@@ -289,6 +294,11 @@
self.assertRaises(errors.OutSideTransaction,
inv.add_lines, 'foo', [], [])
+ def test_supports_external_lookups(self):
+ control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
+ repo = weaverepo.RepositoryFormat7().initialize(control)
+ self.assertFalse(repo._format.supports_external_lookups)
+
class TestFormatKnit1(TestCaseWithTransport):
@@ -404,6 +414,11 @@
inv = repo.deserialise_inventory('other-rev-id', inv_xml)
self.assertEqual('other-rev-id', inv.root.revision)
+ def test_supports_external_lookups(self):
+ repo = self.make_repository('.',
+ format=bzrdir.format_registry.get('knit')())
+ self.assertFalse(repo._format.supports_external_lookups)
+
class KnitRepositoryStreamTests(test_knit.KnitTests):
"""Tests for knitrepo._get_stream_as_bytes."""
@@ -677,6 +692,12 @@
self.assertRaises(errors.OutSideTransaction,
inv.add_lines, 'foo', [], [])
+ def test_supports_external_lookups(self):
+ format = bzrdir.BzrDirMetaFormat1()
+ format.repository_format = knitrepo.RepositoryFormatKnit3()
+ repo = self.make_repository('.', format=format)
+ self.assertFalse(repo._format.supports_external_lookups)
+
class TestWithBrokenRepo(TestCaseWithTransport):
"""These tests seem to be more appropriate as interface tests?"""
@@ -1171,6 +1192,10 @@
self.assertRaises(errors.RevisionNotPresent,
missing_ghost.get_inventory, 'ghost')
+ def test_supports_external_lookups(self):
+ repo = self.make_repository('.', format=self.get_format())
+ self.assertFalse(repo._format.supports_external_lookups)
+
class TestKnitPackSubtrees(TestKnitPackNoSubtrees):
=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py 2008-02-05 22:42:47 +0000
+++ b/bzrlib/tests/test_smart.py 2008-02-12 04:52:18 +0000
@@ -38,9 +38,37 @@
import bzrlib.smart.bzrdir
import bzrlib.smart.branch
import bzrlib.smart.repository
+from bzrlib.tests import (
+ iter_suite_tests,
+ split_suite_by_re,
+ TestScenarioApplier,
+ )
from bzrlib.util import bencode
+def load_tests(standard_tests, module, loader):
+ """Multiply tests version and protocol consistency."""
+ # FindRepository tests.
+ bzrdir_mod = bzrlib.smart.bzrdir
+ applier = TestScenarioApplier()
+ applier.scenarios = [
+ ("find_repository", {
+ "_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV1}),
+ ("find_repositoryV2", {
+ "_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV2}),
+ ]
+ to_adapt, result = split_suite_by_re(standard_tests,
+ "TestSmartServerRequestFindRepository")
+ v2_only, v1_and_2 = split_suite_by_re(to_adapt,
+ "_v2")
+ for test in iter_suite_tests(v1_and_2):
+ result.addTests(applier.adapt(test))
+ del applier.scenarios[0]
+ for test in iter_suite_tests(v2_only):
+ result.addTests(applier.adapt(test))
+ return result
+
+
class TestCaseWithSmartMedium(tests.TestCaseWithTransport):
def setUp(self):
@@ -77,7 +105,7 @@
def test_no_repository(self):
"""When there is no repository to be found, ('norepository', ) is returned."""
backing = self.get_transport()
- request = smart.bzrdir.SmartServerRequestFindRepository(backing)
+ request = self._request_class(backing)
self.make_bzrdir('.')
self.assertEqual(SmartServerResponse(('norepository', )),
request.execute(backing.local_abspath('')))
@@ -87,7 +115,7 @@
# path the repository is being searched on is the same as that that
# the repository is at.
backing = self.get_transport()
- request = smart.bzrdir.SmartServerRequestFindRepository(backing)
+ request = self._request_class(backing)
result = self._make_repository_and_result()
self.assertEqual(result, request.execute(backing.local_abspath('')))
self.make_bzrdir('subdir')
@@ -108,12 +136,19 @@
subtrees = 'yes'
else:
subtrees = 'no'
- return SmartServerResponse(('ok', '', rich_root, subtrees))
+ if (smart.bzrdir.SmartServerRequestFindRepositoryV2 ==
+ self._request_class):
+ # All tests so far are on formats, and for non-external
+ # repositories.
+ return SuccessfulSmartServerResponse(
+ ('ok', '', rich_root, subtrees, 'no'))
+ else:
+ return SuccessfulSmartServerResponse(('ok', '', rich_root, subtrees))
def test_shared_repository(self):
"""When there is a shared repository, we get 'ok', 'relpath-to-repo'."""
backing = self.get_transport()
- request = smart.bzrdir.SmartServerRequestFindRepository(backing)
+ request = self._request_class(backing)
result = self._make_repository_and_result(shared=True)
self.assertEqual(result, request.execute(backing.local_abspath('')))
self.make_bzrdir('subdir')
@@ -128,13 +163,22 @@
def test_rich_root_and_subtree_encoding(self):
"""Test for the format attributes for rich root and subtree support."""
backing = self.get_transport()
- request = smart.bzrdir.SmartServerRequestFindRepository(backing)
+ request = self._request_class(backing)
result = self._make_repository_and_result(format='dirstate-with-subtree')
# check the test will be valid
self.assertEqual('yes', result.args[2])
self.assertEqual('yes', result.args[3])
self.assertEqual(result, request.execute(backing.local_abspath('')))
+ def test_supports_external_lookups_no_v2(self):
+ """Test for the supports_external_lookups attribute."""
+ backing = self.get_transport()
+ request = self._request_class(backing)
+ result = self._make_repository_and_result(format='dirstate-with-subtree')
+ # check the test will be valid
+ self.assertEqual('no', result.args[4])
+ self.assertEqual(result, request.execute(backing.local_abspath('')))
+
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithTransport):
@@ -922,7 +966,10 @@
smart.branch.SmartServerBranchRequestUnlock)
self.assertEqual(
smart.request.request_handlers.get('BzrDir.find_repository'),
- smart.bzrdir.SmartServerRequestFindRepository)
+ smart.bzrdir.SmartServerRequestFindRepositoryV1)
+ self.assertEqual(
+ smart.request.request_handlers.get('BzrDir.find_repositoryV2'),
+ smart.bzrdir.SmartServerRequestFindRepositoryV2)
self.assertEqual(
smart.request.request_handlers.get('BzrDirFormat.initialize'),
smart.bzrdir.SmartServerRequestInitializeBzrDir)
More information about the bazaar-commits
mailing list