Rev 3188: Correctly exclude ghosts when ghosts are started on an existing search. in http://people.ubuntu.com/~robertc/baz2.0/search-results

Robert Collins robertc at robertcollins.net
Wed Jan 16 00:22:10 GMT 2008


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

------------------------------------------------------------
revno: 3188
revision-id:robertc at robertcollins.net-20080116002205-3jwn1aqhu76o97w9
parent: robertc at robertcollins.net-20080116001050-za7seokm1owjr7ee
committer: Robert Collins <robertc at robertcollins.net>
branch nick: search-results
timestamp: Wed 2008-01-16 11:22:05 +1100
message:
  Correctly exclude ghosts when ghosts are started on an existing search.
modified:
  bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
  bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2008-01-16 00:10:50 +0000
+++ b/bzrlib/graph.py	2008-01-16 00:22:05 +0000
@@ -621,6 +621,8 @@
     def _do_query(self, revisions):
         """Query for revisions.
 
+        Adds revisions to the seen set.
+
         :param revisions: Revisions to query.
         :return: A tuple: (set(found_revisions), set(ghost_revisions),
            set(parents_of_found_revisions), dict(found_revisions:parents)).
@@ -703,12 +705,13 @@
         """
         revisions = frozenset(revisions)
         self._started_keys.update(revisions)
+        new_revisions = revisions.difference(self.seen)
+        revs, ghosts, query, parents = self._do_query(revisions)
+        self._stopped_keys.update(ghosts)
         if self._returning == 'next':
-            self._next_query.update(revisions.difference(self.seen))
-            self.seen.update(revisions)
+            self._next_query.update(new_revisions)
         else:
             # perform a query on revisions
-            revs, ghosts, query, parents = self._do_query(revisions)
             self._current_present.update(revs)
             self._current_ghosts.update(ghosts)
             self._next_query.update(query)

=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py	2008-01-16 00:10:50 +0000
+++ b/bzrlib/tests/test_graph.py	2008-01-16 00:22:05 +0000
@@ -828,6 +828,27 @@
         search = graph._make_breadth_first_searcher(['head'])
         self.assertSeenAndRecipes(expected, search, search.next_with_ghosts)
 
+    def test_breadth_first_get_recipe_starting_a_ghost_ghost_is_excluded(self):
+        graph = self.make_graph({
+            'head':['child'],
+            'child':[NULL_REVISION],
+            NULL_REVISION:[],
+            })
+        search = graph._make_breadth_first_searcher(['head'])
+        # using next:
+        expected = [
+            (set(['head', 'ghost']),
+             (set(['head', 'ghost']), set(['child', 'ghost'])),
+             ['ghost'], None),
+            (set(['head', 'child', 'ghost']),
+             (set(['head', 'ghost']), set([NULL_REVISION, 'ghost'])),
+             None, None),
+            ]
+        self.assertSeenAndRecipes(expected, search, search.next)
+        # using next_with_ghosts:
+        search = graph._make_breadth_first_searcher(['head'])
+        self.assertSeenAndRecipes(expected, search, search.next_with_ghosts)
+
 
 class TestCachingParentsProvider(tests.TestCase):
 



More information about the bazaar-commits mailing list