Rev 3204: Backout current_search logic - it shows promise but needs more work. in http://people.ubuntu.com/~robertc/baz2.0/search-results

Robert Collins robertc at robertcollins.net
Sun Feb 3 22:40:18 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/search-results

------------------------------------------------------------
revno: 3204
revision-id:robertc at robertcollins.net-20080203224012-7m1mlpndi0d37pjn
parent: robertc at robertcollins.net-20080203222616-uu4l68ac2j57c427
committer: Robert Collins <robertc at robertcollins.net>
branch nick: Remote_missing_uses_search
timestamp: Mon 2008-02-04 09:40:12 +1100
message:
  Backout current_search logic - it shows promise but needs more work.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
  bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-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-31 03:42:10 +0000
+++ b/NEWS	2008-02-03 22:40:12 +0000
@@ -136,10 +136,6 @@
     * 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/bzrdir.py'
--- a/bzrlib/bzrdir.py	2008-01-18 03:40:35 +0000
+++ b/bzrlib/bzrdir.py	2008-02-03 22:40:12 +0000
@@ -2114,7 +2114,7 @@
         for revision_id in revision_ids:
             yield self.revisions[revision_id].parent_ids
 
-    def get_parent_map(self, revision_ids, current_search=None):
+    def get_parent_map(self, revision_ids):
         """See graph._StackedParentsProvider.get_parent_map"""
         return dict((revision_id, self.revisions[revision_id])
                     for revision_id in revision_ids

=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2008-01-31 03:42:10 +0000
+++ b/bzrlib/graph.py	2008-02-03 22:40:12 +0000
@@ -54,7 +54,7 @@
     def __repr__(self):
         return 'DictParentsProvider(%r)' % self.ancestry
 
-    def get_parent_map(self, keys, current_search=None):
+    def get_parent_map(self, keys):
         """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, current_search=None):
+    def get_parent_map(self, keys):
         """Get a mapping of keys => parents
 
         A dictionary is returned with an entry for each key present in this
@@ -79,12 +79,6 @@
         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 = {}
@@ -112,7 +106,7 @@
     def __repr__(self):
         return "%s(%r)" % (self.__class__.__name__, self._real_provider)
 
-    def get_parent_map(self, keys, current_search=None):
+    def get_parent_map(self, keys):
         """See _StackedParentsProvider.get_parent_map"""
         needed = set()
         # If the _real_provider doesn't have a key, we cache a value of None,
@@ -228,7 +222,7 @@
         parents = self.get_parent_map(revisions)
         return [parent.get(r, None) for r in revisions]
 
-    def get_parent_map(self, revisions, current_search=None):
+    def get_parent_map(self, revisions):
         """Get a map of key:parent_list for revisions.
 
         This implementation delegates to get_parents, for old parent_providers
@@ -521,15 +515,7 @@
             # look-ahead result buffer and shuffle things around, this method
             # is typically only called once per search - when memoising the
             # results of the search. 
-            # XXX: TODO: NOTE: ote that we cannot supply the current search to
-            # the call to get_parent_map in this case because it leads to
-            # infinite recursion. (remote.g_p_m -> get_result ->
-            # remote.get_parent_map) - the revisions needed to determine what
-            # keys to exclude to recreate current state are precisely those
-            # being queried. This is likely a problem that will need to be
-            # addressed (perhaps by extending the search recipe to have two
-            # exclude lists - exclude_from and exclude_at). - RBC 20080118
-            found, ghosts, next, parents = self._do_query(self._next_query, False)
+            found, ghosts, next, parents = self._do_query(self._next_query)
             # pretend we didn't query: perhaps we should tweak _do_query to be
             # entirely stateless?
             self.seen.difference_update(next)
@@ -602,7 +588,7 @@
         # repeated when ghosts are filled.
         self._stopped_keys.update(ghosts)
 
-    def _do_query(self, revisions, provide_self=True):
+    def _do_query(self, revisions):
         """Query for revisions.
 
         Adds revisions to the seen set.
@@ -616,12 +602,7 @@
         # revisions may contain nodes that point to other nodes in revisions:
         # we want to filter them out.
         self.seen.update(revisions)
-        if provide_self:
-            current_search = self
-        else:
-            current_search = None
-        parent_map = self._parents_provider.get_parent_map(revisions,
-            current_search)
+        parent_map = self._parents_provider.get_parent_map(revisions)
         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/index.py'
--- a/bzrlib/index.py	2008-01-18 03:40:35 +0000
+++ b/bzrlib/index.py	2008-02-03 22:40:12 +0000
@@ -1016,7 +1016,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, current_search=None):
+    def get_parent_map(self, keys):
         """See graph._StackedParentsProvider.get_parent_map"""
         search_keys = set(keys)
         if NULL_REVISION in search_keys:

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2008-02-03 22:26:16 +0000
+++ b/bzrlib/remote.py	2008-02-03 22:40:12 +0000
@@ -769,7 +769,7 @@
         self._ensure_real()
         return self._real_repository.iter_files_bytes(desired_files)
 
-    def get_parent_map(self, keys, current_search=None):
+    def get_parent_map(self, keys):
         """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-18 02:36:57 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2008-02-03 22:40:12 +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, current_search=None):
+    def get_parent_map(self, keys):
         """See graph._StackedParentsProvider.get_parent_map"""
         parent_map = {}
         for revision_id in keys:

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2008-01-31 03:38:51 +0000
+++ b/bzrlib/repository.py	2008-02-03 22:40:12 +0000
@@ -1752,7 +1752,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, current_search=None):
+    def get_parent_map(self, keys):
         """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-31 03:38:51 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py	2008-02-03 22:40:12 +0000
@@ -604,8 +604,8 @@
         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."""
+    def test_get_parent_map_corner_cases(self):
+        """get_parent_map(keys) must work on a repo's graph."""
         repo = self.make_repository('.')
         repo.lock_read()
         self.addCleanup(repo.unlock)

=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py	2008-01-18 02:36:57 +0000
+++ b/bzrlib/tests/test_graph.py	2008-02-03 22:40:12 +0000
@@ -244,9 +244,9 @@
         self.calls = []
         self._real_parents_provider = parents_provider
 
-    def get_parent_map(self, nodes, current_search=None):
+    def get_parent_map(self, nodes):
         self.calls.extend(nodes)
-        return self._real_parents_provider.get_parent_map(nodes, current_search)
+        return self._real_parents_provider.get_parent_map(nodes)
 
 
 class TestGraph(TestCaseWithMemoryTransport):
@@ -599,7 +599,7 @@
         """
         class stub(object):
             pass
-        def get_parent_map(keys, current_search=None):
+        def get_parent_map(keys):
             result = {}
             for key in keys:
                 if key == 'deeper':



More information about the bazaar-commits mailing list