Rev 3193: Merge up ghost handling fix. in http://people.ubuntu.com/~robertc/baz2.0/search-results
Robert Collins
robertc at robertcollins.net
Thu Jan 17 23:21:31 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/search-results
------------------------------------------------------------
revno: 3193
revision-id:robertc at robertcollins.net-20080117232125-qfir5s2qg23jnucs
parent: robertc at robertcollins.net-20080117031420-zrmkezusngok2437
parent: robertc at robertcollins.net-20080117224132-z2plxu9lh0g3rpz7
committer: Robert Collins <robertc at robertcollins.net>
branch nick: use-SearchResult
timestamp: Fri 2008-01-18 10:21:25 +1100
message:
Merge up ghost handling fix.
modified:
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/tests/test_graph.py test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
------------------------------------------------------------
revno: 3191.1.1
revision-id:robertc at robertcollins.net-20080117224132-z2plxu9lh0g3rpz7
parent: robertc at robertcollins.net-20080116012748-anci5pui3pdx9ypy
committer: Robert Collins <robertc at robertcollins.net>
branch nick: search-results
timestamp: Fri 2008-01-18 09:41:32 +1100
message:
Handle stopping ghosts in searches properly.
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 01:25:39 +0000
+++ b/bzrlib/graph.py 2008-01-17 22:41:32 +0000
@@ -660,15 +660,15 @@
stopped = self._next_query.intersection(revisions)
self._next_query = self._next_query.difference(revisions)
else:
- stopped = set()
- stopped.update(self._current_present.intersection(revisions))
- stopped.update(self._current_ghosts.intersection(revisions))
+ stopped_present = self._current_present.intersection(revisions)
+ stopped = stopped_present.union(
+ self._current_ghosts.intersection(revisions))
self._current_present.difference_update(stopped)
self._current_ghosts.difference_update(stopped)
# stopping 'x' should stop returning parents of 'x', but
# not if 'y' always references those same parents
stop_rev_references = {}
- for rev in stopped:
+ for rev in stopped_present:
for parent_id in self._current_parents[rev]:
if parent_id not in stop_rev_references:
stop_rev_references[parent_id] = 0
=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py 2008-01-16 01:25:39 +0000
+++ b/bzrlib/tests/test_graph.py 2008-01-17 22:41:32 +0000
@@ -818,6 +818,30 @@
search.start_searching(['head'])
self.assertSeenAndResult(expected, search, search.next_with_ghosts)
+ def test_breadth_first_stop_searching_not_queried(self):
+ # A client should be able to say 'stop node X' even if X has not been
+ # returned to the client.
+ graph = self.make_graph({
+ 'head':['child', 'ghost1'],
+ 'child':[NULL_REVISION],
+ NULL_REVISION:[],
+ })
+ search = graph._make_breadth_first_searcher(['head'])
+ expected = [
+ # NULL_REVISION and ghost1 have not been returned
+ (set(['head']), (set(['head']), set(['child', 'ghost1']), 1),
+ ['head'], None, [NULL_REVISION, 'ghost1']),
+ # ghost1 has been returned, NULL_REVISION is to be returned in the
+ # next iteration.
+ (set(['head', 'child', 'ghost1']),
+ (set(['head']), set(['ghost1', NULL_REVISION]), 2),
+ ['head', 'child'], None, [NULL_REVISION, 'ghost1']),
+ ]
+ self.assertSeenAndResult(expected, search, search.next)
+ # using next_with_ghosts:
+ search = graph._make_breadth_first_searcher(['head'])
+ self.assertSeenAndResult(expected, search, search.next_with_ghosts)
+
def test_breadth_first_get_result_ghosts_are_excluded(self):
graph = self.make_graph({
'head':['child', 'ghost'],
More information about the bazaar-commits
mailing list