Rev 3232: Basic stacked repository test passing. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch
Robert Collins
robertc at robertcollins.net
Mon Feb 18 01:24:21 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/shallow-branch
------------------------------------------------------------
revno: 3232
revision-id:robertc at robertcollins.net-20080218012400-leflc5bt8j2ftt94
parent: robertc at robertcollins.net-20080215033013-lej7ll35xy59m4x5
committer: Robert Collins <robertc at robertcollins.net>
branch nick: StackablePacks
timestamp: Mon 2008-02-18 12:24:00 +1100
message:
Basic stacked repository test passing.
added:
bzrlib/tests/repository_implementations/test_add_fallback_repository.py test_add_fallback_re-20080215040003-8w9n4ck9uqdxj18m-1
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-02-14 00:40:32 +0000
+++ b/bzrlib/remote.py 2008-02-18 01:24:00 +0000
@@ -300,6 +300,8 @@
# Can this repository be given external locations to lookup additional
# data.
self.supports_external_lookups = False
+ # Additional places to query for data.
+ self._fallback_repositories = []
def __str__(self):
return "%s(%s)" % (self.__class__.__name__, self.base)
@@ -678,6 +680,17 @@
committer=committer, revprops=revprops, revision_id=revision_id)
return builder
+ def add_fallback_repository(self, repository):
+ """Add a repository to use for looking up data not held locally.
+
+ :param repository: A repository.
+ """
+ if not self._format.supports_external_lookups:
+ raise errors.UnstackableRepositoryFormat(self._format, self.base)
+ # We need to accumulate additional repositories here, to pass them in
+ # on various RPC's.
+ self._fallback_repositories.append(repository)
+
def add_inventory(self, revid, inv, parents):
self._ensure_real()
return self._real_repository.add_inventory(revid, inv, parents)
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2008-02-15 02:30:52 +0000
+++ b/bzrlib/repository.py 2008-02-18 01:24:00 +0000
@@ -495,6 +495,15 @@
attempted.
"""
+ def add_fallback_repository(self, repository):
+ """Add a repository to use for looking up data not held locally.
+
+ :param repository: A repository.
+ """
+ if not self._format.supports_external_lookups:
+ raise errors.UnstackableRepositoryFormat(self._format, self.base)
+ self._fallback_repositories.append(repository)
+
def add_inventory(self, revision_id, inv, parents):
"""Add the inventory inv to the repository as revision_id.
@@ -563,13 +572,17 @@
def all_revision_ids(self):
"""Returns a list of all the revision ids in the repository.
- This is deprecated because code should generally work on the graph
- reachable from a particular revision, and ignore any other revisions
- that might be present. There is no direct replacement method.
+ This is conceptually deprecated because code should generally work on
+ the graph reachable from a particular revision, and ignore any other
+ revisions that might be present. There is no direct replacement
+ method.
"""
if 'evil' in debug.debug_flags:
mutter_callsite(2, "all_revision_ids is linear with history.")
- return self._all_revision_ids()
+ all_ids = set(self._all_revision_ids())
+ for repository in self._fallback_repositories:
+ all_ids.update(repository.all_revision_ids())
+ return all_ids
def _all_revision_ids(self):
"""Returns a list of all the revision ids in the repository.
@@ -635,6 +648,8 @@
self._warn_if_deprecated()
self._write_group = None
self.base = control_files._transport.base
+ # Additional places to query for data.
+ self._fallback_repositories = []
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__,
=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py 2008-01-11 03:54:51 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py 2008-02-18 01:24:00 +0000
@@ -859,6 +859,7 @@
prefix = 'bzrlib.tests.repository_implementations.'
test_repository_modules = [
+ 'test_add_fallback_repository',
'test_break_lock',
'test_check',
# test_check_reconcile is intentionally omitted, see below.
=== added file 'bzrlib/tests/repository_implementations/test_add_fallback_repository.py'
--- a/bzrlib/tests/repository_implementations/test_add_fallback_repository.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_implementations/test_add_fallback_repository.py 2008-02-18 01:24:00 +0000
@@ -0,0 +1,36 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Tests for Repository.add_fallback_repository."""
+
+from bzrlib import errors
+from bzrlib.tests import TestNotApplicable
+from bzrlib.tests.repository_implementations import TestCaseWithRepository
+
+
+class TestAddFallbackRepository(TestCaseWithRepository):
+
+ def test_add_fallback_repository(self):
+ repo = self.make_repository('repo')
+ tree = self.make_branch_and_tree('branch')
+ if not repo._format.supports_external_lookups:
+ self.assertRaises(errors.UnstackableRepositoryFormat,
+ repo.add_fallback_repository, tree.branch.repository)
+ raise TestNotApplicable
+ repo.add_fallback_repository(tree.branch.repository)
+ # the repository has been added correctly if we can query against it.
+ revision_id = tree.commit('1st post')
+ self.assertEqual(set([revision_id]), set(repo.all_revision_ids()))
More information about the bazaar-commits
mailing list