Rev 3174: Create a RemoteRepository get_graph implementation and delegate get_parents_map to the real repository. in http://people.ubuntu.com/~robertc/baz2.0/remote.graph

Robert Collins robertc at robertcollins.net
Thu Jan 10 22:34:11 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/remote.graph

------------------------------------------------------------
revno: 3174
revision-id:robertc at robertcollins.net-20080110223405-uuaxxfwv44b3ptp0
parent: robertc at robertcollins.net-20080110220839-ze9uhnjp04h7y9mp
committer: Robert Collins <robertc at robertcollins.net>
branch nick: remote.graph
timestamp: Fri 2008-01-11 09:34:05 +1100
message:
  Create a RemoteRepository get_graph implementation and delegate get_parents_map to the real repository.
modified:
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2008-01-07 01:27:38 +0000
+++ b/bzrlib/remote.py	2008-01-10 22:34:05 +0000
@@ -22,6 +22,7 @@
 from bzrlib import (
     branch,
     errors,
+    graph,
     lockdir,
     repository,
     revision,
@@ -381,8 +382,13 @@
         
     def get_graph(self, other_repository=None):
         """Return the graph for this repository format"""
-        self._ensure_real()
-        return self._real_repository.get_graph(other_repository)
+        parents_provider = self
+        if (other_repository is not None and
+            other_repository.bzrdir.transport.base !=
+            self.bzrdir.transport.base):
+            parents_provider = graph._StackedParentsProvider(
+                [parents_provider, other_repository._make_parents_provider()])
+        return graph.Graph(parents_provider)
 
     def gather_stats(self, revid=None, committers=None):
         """See Repository.gather_stats()."""
@@ -906,8 +912,13 @@
         return self._real_repository._check_for_inconsistent_revision_parents()
 
     def _make_parents_provider(self):
+        return self
+
+    def get_parent_map(self, keys):
+        # Thunk across to real for now.
         self._ensure_real()
-        return self._real_repository._make_parents_provider()
+        return self._real_repository._make_parents_provider().get_parent_map(
+            keys)
 
 
 class RemoteBranchLockableFiles(LockableFiles):

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2007-10-12 06:24:42 +0000
+++ b/bzrlib/tests/test_remote.py	2008-01-10 22:34:05 +0000
@@ -478,6 +478,18 @@
         return repo, client
 
 
+class TestRepositoryGetGraph(TestRemoteRepository):
+
+    def test_get_graph(self):
+        # get_graph returns a graph with get_parent_map as the repository.
+        responses = []
+        transport_path = 'quack'
+        repo, client = self.setup_fake_client_and_repository(
+            responses, transport_path)
+        graph = repo.get_graph()
+        self.assertEqual(graph._parents_provider, repo)
+
+
 class TestRepositoryGatherStats(TestRemoteRepository):
 
     def test_revid_none(self):



More information about the bazaar-commits mailing list