Rev 3193: * The ``Graph.get_parent_map`` call now accepts an optional parameter in http://people.ubuntu.com/~robertc/baz2.0/search-results
Robert Collins
robertc at robertcollins.net
Fri Jan 18 02:37:13 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/search-results
------------------------------------------------------------
revno: 3193
revision-id:robertc at robertcollins.net-20080118023657-1uxxihxthnarju4q
parent: pqm at pqm.ubuntu.com-20080118011625-465mgy0mhdz1jiky
committer: Robert Collins <robertc at robertcollins.net>
branch nick: get_parent_map
timestamp: Fri 2008-01-18 13:36:57 +1100
message:
* The ``Graph.get_parent_map`` call now accepts an optional parameter
current_search which allows filtering of duplicate results in smart
server calls by reconstructing the client state. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_graph.py test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
=== modified file 'NEWS'
--- a/NEWS 2008-01-17 23:45:03 +0000
+++ b/NEWS 2008-01-18 02:36:57 +0000
@@ -92,6 +92,10 @@
* RemoteTransport's ``recommended_page_size`` method now returns 64k, like
SFTPTransport and HttpTransportBase. (Andrew Bennetts)
+ * The ``Graph.get_parent_map`` call now accepts an optional parameter
+ current_search which allows filtering of duplicate results in smart
+ server calls by reconstructing the client state. (Robert Collins)
+
bzr 1.1 2008-01-15
------------------
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py 2008-01-17 22:41:32 +0000
+++ b/bzrlib/graph.py 2008-01-18 02:36:57 +0000
@@ -54,7 +54,7 @@
def __repr__(self):
return 'DictParentsProvider(%r)' % self.ancestry
- def get_parent_map(self, keys):
+ def get_parent_map(self, keys, current_search=None):
"""See _StackedParentsProvider.get_parent_map"""
ancestry = self.ancestry
return dict((k, ancestry[k]) for k in keys if k in ancestry)
@@ -68,7 +68,7 @@
def __repr__(self):
return "_StackedParentsProvider(%r)" % self._parent_providers
- def get_parent_map(self, keys):
+ def get_parent_map(self, keys, current_search=None):
"""Get a mapping of keys => parents
A dictionary is returned with an entry for each key present in this
@@ -79,6 +79,12 @@
revision. Its parent list is empty.
:param keys: An iterable returning keys to check (eg revision_ids)
+ :param current_search: An optional _BreadthFirstSearcher which is being
+ used to search for revisions. This can be used to obtain the
+ revisions already considered by the graph client; this is primarily
+ relevant for smart server requests where we wish to avoid sending
+ duplicate data over the wire and listing all the seen revisions is
+ very expensive.
:return: A dictionary mapping each key to its parents
"""
found = {}
@@ -106,7 +112,7 @@
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self._real_provider)
- def get_parent_map(self, keys):
+ def get_parent_map(self, keys, current_search=None):
"""See _StackedParentsProvider.get_parent_map"""
needed = set()
# If the _real_provider doesn't have a key, we cache a value of None,
@@ -222,7 +228,7 @@
parents = self.get_parent_map(revisions)
return [parent.get(r, None) for r in revisions]
- def get_parent_map(self, revisions):
+ def get_parent_map(self, revisions, current_search=None):
"""Get a map of key:parent_list for revisions.
This implementation delegates to get_parents, for old parent_providers
@@ -626,7 +632,7 @@
# revisions may contain nodes that point to other nodes in revisions:
# we want to filter them out.
self.seen.update(revisions)
- parent_map = self._parents_provider.get_parent_map(revisions)
+ parent_map = self._parents_provider.get_parent_map(revisions, self)
for rev_id, parents in parent_map.iteritems():
found_parents.add(rev_id)
parents_of_found.update(p for p in parents if p not in self.seen)
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-01-17 07:47:52 +0000
+++ b/bzrlib/remote.py 2008-01-18 02:36:57 +0000
@@ -761,7 +761,7 @@
self._ensure_real()
return self._real_repository.iter_files_bytes(desired_files)
- def get_parent_map(self, keys):
+ def get_parent_map(self, keys, current_search=None):
"""See bzrlib.Graph.get_parent_map()."""
# Hack to build up the caching logic.
ancestry = self._parents_map
=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py 2008-01-17 05:30:53 +0000
+++ b/bzrlib/repofmt/knitrepo.py 2008-01-18 02:36:57 +0000
@@ -65,7 +65,7 @@
parent_map = self.get_parent_map(revision_ids)
return [parent_map.get(r, None) for r in revision_ids]
- def get_parent_map(self, keys):
+ def get_parent_map(self, keys, current_search=None):
"""See graph._StackedParentsProvider.get_parent_map"""
parent_map = {}
for revision_id in keys:
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2008-01-17 05:30:53 +0000
+++ b/bzrlib/repository.py 2008-01-18 02:36:57 +0000
@@ -1754,7 +1754,7 @@
parent_map = self.get_parent_map(revision_ids)
return [parent_map.get(r, None) for r in revision_ids]
- def get_parent_map(self, keys):
+ def get_parent_map(self, keys, current_search=None):
"""See graph._StackedParentsProvider.get_parent_map"""
parent_map = {}
for revision_id in keys:
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py 2008-01-17 05:30:53 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py 2008-01-18 02:36:57 +0000
@@ -584,6 +584,18 @@
for value in parents.values():
self.assertIsInstance(value, tuple)
+ def test_get_parent_map_current_search(self):
+ """get_parent_map(keys, current_search) must work on a repo's graph."""
+ repo = self.make_repository('.')
+ repo.lock_read()
+ self.addCleanup(repo.unlock)
+ graph = repo.get_graph()
+ # With no search, no error
+ self.assertEqual({}, graph.get_parent_map([], None))
+ # And with a search, no error
+ search = graph._make_breadth_first_searcher([])
+ self.assertEqual({}, graph.get_parent_map([], search))
+
def test_implements_revision_graph_can_have_wrong_parents(self):
"""All repositories should implement
revision_graph_can_have_wrong_parents, so that check and reconcile can
=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py 2008-01-17 22:41:32 +0000
+++ b/bzrlib/tests/test_graph.py 2008-01-18 02:36:57 +0000
@@ -244,9 +244,9 @@
self.calls = []
self._real_parents_provider = parents_provider
- def get_parent_map(self, nodes):
+ def get_parent_map(self, nodes, current_search=None):
self.calls.extend(nodes)
- return self._real_parents_provider.get_parent_map(nodes)
+ return self._real_parents_provider.get_parent_map(nodes, current_search)
class TestGraph(TestCaseWithMemoryTransport):
@@ -599,7 +599,7 @@
"""
class stub(object):
pass
- def get_parent_map(keys):
+ def get_parent_map(keys, current_search=None):
result = {}
for key in keys:
if key == 'deeper':
More information about the bazaar-commits
mailing list