/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Robert Collins
  • Date: 2008-02-06 04:06:42 UTC
  • mfrom: (3216 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3217.
  • Revision ID: robertc@robertcollins.net-20080206040642-2efx3l4iv5f95lxp
Merge up with bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
These tests correspond to tests.test_smart, which exercises the server side.
24
24
"""
25
25
 
 
26
import bz2
26
27
from cStringIO import StringIO
27
28
 
28
29
from bzrlib import (
29
 
    bzrdir,
30
30
    errors,
 
31
    graph,
31
32
    pack,
32
33
    remote,
33
34
    repository,
108
109
    """Lookalike SmartClientRequestProtocolOne allowing body reading tests."""
109
110
 
110
111
    def __init__(self, body, fake_client):
111
 
        self._body_buffer = StringIO(body)
 
112
        self.body = body
 
113
        self._body_buffer = None
112
114
        self._fake_client = fake_client
113
115
 
114
116
    def read_body_bytes(self, count=-1):
 
117
        if self._body_buffer is None:
 
118
            self._body_buffer = StringIO(self.body)
115
119
        bytes = self._body_buffer.read(count)
116
120
        if self._body_buffer.tell() == len(self._body_buffer.getvalue()):
117
121
            self._fake_client.expecting_body = False
120
124
    def cancel_read_body(self):
121
125
        self._fake_client.expecting_body = False
122
126
 
 
127
    def read_streamed_body(self):
 
128
        return self.body
 
129
 
123
130
 
124
131
class FakeClient(_SmartClient):
125
132
    """Lookalike for _SmartClient allowing testing."""
126
133
    
127
 
    def __init__(self, responses):
128
 
        # We don't call the super init because there is no medium.
 
134
    def __init__(self, responses, fake_medium_base='fake base'):
129
135
        """Create a FakeClient.
130
136
 
131
 
        :param respones: A list of response-tuple, body-data pairs to be sent
 
137
        :param responses: A list of response-tuple, body-data pairs to be sent
132
138
            back to callers.
133
139
        """
134
140
        self.responses = responses
135
141
        self._calls = []
136
142
        self.expecting_body = False
 
143
        _SmartClient.__init__(self, FakeMedium(fake_medium_base))
137
144
 
138
145
    def call(self, method, *args):
139
146
        self._calls.append(('call', method, args))
145
152
        self.expecting_body = True
146
153
        return result[0], FakeProtocol(result[1], self)
147
154
 
 
155
    def call_with_body_bytes_expecting_body(self, method, args, body):
 
156
        self._calls.append(('call_with_body_bytes_expecting_body', method,
 
157
            args, body))
 
158
        result = self.responses.pop(0)
 
159
        self.expecting_body = True
 
160
        return result[0], FakeProtocol(result[1], self)
 
161
 
 
162
 
 
163
class FakeMedium(object):
 
164
 
 
165
    def __init__(self, base):
 
166
        self.base = base
 
167
 
 
168
 
 
169
class TestVfsHas(tests.TestCase):
 
170
 
 
171
    def test_unicode_path(self):
 
172
        client = FakeClient([(('yes',), )], '/')
 
173
        transport = RemoteTransport('bzr://localhost/', _client=client)
 
174
        filename = u'/hell\u00d8'.encode('utf8')
 
175
        result = transport.has(filename)
 
176
        self.assertEqual(
 
177
            [('call', 'has', (filename,))],
 
178
            client._calls)
 
179
        self.assertTrue(result)
 
180
 
148
181
 
149
182
class TestBzrDirOpenBranch(tests.TestCase):
150
183
 
151
184
    def test_branch_present(self):
152
 
        client = FakeClient([(('ok', ''), ), (('ok', '', 'no', 'no'), )])
153
185
        transport = MemoryTransport()
154
186
        transport.mkdir('quack')
155
187
        transport = transport.clone('quack')
 
188
        client = FakeClient([(('ok', ''), ), (('ok', '', 'no', 'no'), )],
 
189
                            transport.base)
156
190
        bzrdir = RemoteBzrDir(transport, _client=client)
157
191
        result = bzrdir.open_branch()
158
192
        self.assertEqual(
159
 
            [('call', 'BzrDir.open_branch', ('///quack/',)),
160
 
             ('call', 'BzrDir.find_repository', ('///quack/',))],
 
193
            [('call', 'BzrDir.open_branch', ('quack/',)),
 
194
             ('call', 'BzrDir.find_repository', ('quack/',))],
161
195
            client._calls)
162
196
        self.assertIsInstance(result, RemoteBranch)
163
197
        self.assertEqual(bzrdir, result.bzrdir)
164
198
 
165
199
    def test_branch_missing(self):
166
 
        client = FakeClient([(('nobranch',), )])
167
200
        transport = MemoryTransport()
168
201
        transport.mkdir('quack')
169
202
        transport = transport.clone('quack')
 
203
        client = FakeClient([(('nobranch',), )], transport.base)
170
204
        bzrdir = RemoteBzrDir(transport, _client=client)
171
205
        self.assertRaises(errors.NotBranchError, bzrdir.open_branch)
172
206
        self.assertEqual(
173
 
            [('call', 'BzrDir.open_branch', ('///quack/',))],
 
207
            [('call', 'BzrDir.open_branch', ('quack/',))],
 
208
            client._calls)
 
209
 
 
210
    def test__get_tree_branch(self):
 
211
        # _get_tree_branch is a form of open_branch, but it should only ask for
 
212
        # branch opening, not any other network requests.
 
213
        calls = []
 
214
        def open_branch():
 
215
            calls.append("Called")
 
216
            return "a-branch"
 
217
        transport = MemoryTransport()
 
218
        # no requests on the network - catches other api calls being made.
 
219
        client = FakeClient([], transport.base)
 
220
        bzrdir = RemoteBzrDir(transport, _client=client)
 
221
        # patch the open_branch call to record that it was called.
 
222
        bzrdir.open_branch = open_branch
 
223
        self.assertEqual((None, "a-branch"), bzrdir._get_tree_branch())
 
224
        self.assertEqual(["Called"], calls)
 
225
        self.assertEqual([], client._calls)
 
226
 
 
227
    def test_url_quoting_of_path(self):
 
228
        # Relpaths on the wire should not be URL-escaped.  So "~" should be
 
229
        # transmitted as "~", not "%7E".
 
230
        transport = RemoteTransport('bzr://localhost/~hello/')
 
231
        client = FakeClient([(('ok', ''), ), (('ok', '', 'no', 'no'), )],
 
232
                            transport.base)
 
233
        bzrdir = RemoteBzrDir(transport, _client=client)
 
234
        result = bzrdir.open_branch()
 
235
        self.assertEqual(
 
236
            [('call', 'BzrDir.open_branch', ('~hello/',)),
 
237
             ('call', 'BzrDir.find_repository', ('~hello/',))],
174
238
            client._calls)
175
239
 
176
240
    def check_open_repository(self, rich_root, subtrees):
 
241
        transport = MemoryTransport()
 
242
        transport.mkdir('quack')
 
243
        transport = transport.clone('quack')
177
244
        if rich_root:
178
245
            rich_response = 'yes'
179
246
        else:
182
249
            subtree_response = 'yes'
183
250
        else:
184
251
            subtree_response = 'no'
185
 
        client = FakeClient([(('ok', '', rich_response, subtree_response), ),])
186
 
        transport = MemoryTransport()
187
 
        transport.mkdir('quack')
188
 
        transport = transport.clone('quack')
 
252
        client = FakeClient([(('ok', '', rich_response, subtree_response), ),],
 
253
                            transport.base)
189
254
        bzrdir = RemoteBzrDir(transport, _client=client)
190
255
        result = bzrdir.open_repository()
191
256
        self.assertEqual(
192
 
            [('call', 'BzrDir.find_repository', ('///quack/',))],
 
257
            [('call', 'BzrDir.find_repository', ('quack/',))],
193
258
            client._calls)
194
259
        self.assertIsInstance(result, RemoteRepository)
195
260
        self.assertEqual(bzrdir, result.bzrdir)
239
304
 
240
305
    def test_empty_branch(self):
241
306
        # in an empty branch we decode the response properly
242
 
        client = FakeClient([(('ok', '0', 'null:'), )])
243
307
        transport = MemoryTransport()
 
308
        client = FakeClient([(('ok', '0', 'null:'), )], transport.base)
244
309
        transport.mkdir('quack')
245
310
        transport = transport.clone('quack')
246
311
        # we do not want bzrdir to make any remote calls
249
314
        result = branch.last_revision_info()
250
315
 
251
316
        self.assertEqual(
252
 
            [('call', 'Branch.last_revision_info', ('///quack/',))],
 
317
            [('call', 'Branch.last_revision_info', ('quack/',))],
253
318
            client._calls)
254
319
        self.assertEqual((0, NULL_REVISION), result)
255
320
 
256
321
    def test_non_empty_branch(self):
257
322
        # in a non-empty branch we also decode the response properly
258
323
        revid = u'\xc8'.encode('utf8')
259
 
        client = FakeClient([(('ok', '2', revid), )])
260
324
        transport = MemoryTransport()
 
325
        client = FakeClient([(('ok', '2', revid), )], transport.base)
261
326
        transport.mkdir('kwaak')
262
327
        transport = transport.clone('kwaak')
263
328
        # we do not want bzrdir to make any remote calls
266
331
        result = branch.last_revision_info()
267
332
 
268
333
        self.assertEqual(
269
 
            [('call', 'Branch.last_revision_info', ('///kwaak/',))],
 
334
            [('call', 'Branch.last_revision_info', ('kwaak/',))],
270
335
            client._calls)
271
336
        self.assertEqual((2, revid), result)
272
337
 
276
341
    def test_set_empty(self):
277
342
        # set_revision_history([]) is translated to calling
278
343
        # Branch.set_last_revision(path, '') on the wire.
 
344
        transport = MemoryTransport()
 
345
        transport.mkdir('branch')
 
346
        transport = transport.clone('branch')
 
347
 
279
348
        client = FakeClient([
280
349
            # lock_write
281
350
            (('ok', 'branch token', 'repo token'), ),
282
351
            # set_last_revision
283
352
            (('ok',), ),
284
353
            # unlock
285
 
            (('ok',), )])
286
 
        transport = MemoryTransport()
287
 
        transport.mkdir('branch')
288
 
        transport = transport.clone('branch')
289
 
 
 
354
            (('ok',), )],
 
355
            transport.base)
290
356
        bzrdir = RemoteBzrDir(transport, _client=False)
291
357
        branch = RemoteBranch(bzrdir, None, _client=client)
292
358
        # This is a hack to work around the problem that RemoteBranch currently
297
363
        result = branch.set_revision_history([])
298
364
        self.assertEqual(
299
365
            [('call', 'Branch.set_last_revision',
300
 
                ('///branch/', 'branch token', 'repo token', 'null:'))],
 
366
                ('branch/', 'branch token', 'repo token', 'null:'))],
301
367
            client._calls)
302
368
        branch.unlock()
303
369
        self.assertEqual(None, result)
305
371
    def test_set_nonempty(self):
306
372
        # set_revision_history([rev-id1, ..., rev-idN]) is translated to calling
307
373
        # Branch.set_last_revision(path, rev-idN) on the wire.
 
374
        transport = MemoryTransport()
 
375
        transport.mkdir('branch')
 
376
        transport = transport.clone('branch')
 
377
 
308
378
        client = FakeClient([
309
379
            # lock_write
310
380
            (('ok', 'branch token', 'repo token'), ),
311
381
            # set_last_revision
312
382
            (('ok',), ),
313
383
            # unlock
314
 
            (('ok',), )])
315
 
        transport = MemoryTransport()
316
 
        transport.mkdir('branch')
317
 
        transport = transport.clone('branch')
318
 
 
 
384
            (('ok',), )],
 
385
            transport.base)
319
386
        bzrdir = RemoteBzrDir(transport, _client=False)
320
387
        branch = RemoteBranch(bzrdir, None, _client=client)
321
388
        # This is a hack to work around the problem that RemoteBranch currently
328
395
        result = branch.set_revision_history(['rev-id1', 'rev-id2'])
329
396
        self.assertEqual(
330
397
            [('call', 'Branch.set_last_revision',
331
 
                ('///branch/', 'branch token', 'repo token', 'rev-id2'))],
 
398
                ('branch/', 'branch token', 'repo token', 'rev-id2'))],
332
399
            client._calls)
333
400
        branch.unlock()
334
401
        self.assertEqual(None, result)
368
435
 
369
436
    def test_get_branch_conf(self):
370
437
        # in an empty branch we decode the response properly
371
 
        client = FakeClient([(('ok', ), 'config file body')])
 
438
        client = FakeClient([(('ok', ), 'config file body')], self.get_url())
372
439
        # we need to make a real branch because the remote_branch.control_files
373
440
        # will trigger _ensure_real.
374
441
        branch = self.make_branch('quack')
378
445
        branch = RemoteBranch(bzrdir, None, _client=client)
379
446
        result = branch.control_files.get('branch.conf')
380
447
        self.assertEqual(
381
 
            [('call_expecting_body', 'Branch.get_config_file', ('///quack/',))],
 
448
            [('call_expecting_body', 'Branch.get_config_file', ('quack/',))],
382
449
            client._calls)
383
450
        self.assertEqual('config file body', result.read())
384
451
 
386
453
class TestBranchLockWrite(tests.TestCase):
387
454
 
388
455
    def test_lock_write_unlockable(self):
389
 
        client = FakeClient([(('UnlockableTransport', ), '')])
390
456
        transport = MemoryTransport()
 
457
        client = FakeClient([(('UnlockableTransport', ), '')], transport.base)
391
458
        transport.mkdir('quack')
392
459
        transport = transport.clone('quack')
393
460
        # we do not want bzrdir to make any remote calls
395
462
        branch = RemoteBranch(bzrdir, None, _client=client)
396
463
        self.assertRaises(errors.UnlockableTransport, branch.lock_write)
397
464
        self.assertEqual(
398
 
            [('call', 'Branch.lock_write', ('///quack/', '', ''))],
 
465
            [('call', 'Branch.lock_write', ('quack/', '', ''))],
399
466
            client._calls)
400
467
 
401
468
 
468
535
        :param transport_path: Path below the root of the MemoryTransport
469
536
            where the repository will be created.
470
537
        """
471
 
        client = FakeClient(responses)
472
538
        transport = MemoryTransport()
473
539
        transport.mkdir(transport_path)
 
540
        client = FakeClient(responses, transport.base)
474
541
        transport = transport.clone(transport_path)
475
542
        # we do not want bzrdir to make any remote calls
476
543
        bzrdir = RemoteBzrDir(transport, _client=False)
489
556
        result = repo.gather_stats(None)
490
557
        self.assertEqual(
491
558
            [('call_expecting_body', 'Repository.gather_stats',
492
 
             ('///quack/','','no'))],
 
559
             ('quack/','','no'))],
493
560
            client._calls)
494
561
        self.assertEqual({'revisions': 2, 'size': 18}, result)
495
562
 
507
574
        result = repo.gather_stats(revid)
508
575
        self.assertEqual(
509
576
            [('call_expecting_body', 'Repository.gather_stats',
510
 
              ('///quick/', revid, 'no'))],
 
577
              ('quick/', revid, 'no'))],
511
578
            client._calls)
512
579
        self.assertEqual({'revisions': 2, 'size': 18,
513
580
                          'firstrev': (123456.300, 3600),
529
596
        result = repo.gather_stats(revid, True)
530
597
        self.assertEqual(
531
598
            [('call_expecting_body', 'Repository.gather_stats',
532
 
              ('///buick/', revid, 'yes'))],
 
599
              ('buick/', revid, 'yes'))],
533
600
            client._calls)
534
601
        self.assertEqual({'revisions': 2, 'size': 18,
535
602
                          'committers': 128,
538
605
                         result)
539
606
 
540
607
 
 
608
class TestRepositoryGetGraph(TestRemoteRepository):
 
609
 
 
610
    def test_get_graph(self):
 
611
        # get_graph returns a graph with the repository as the
 
612
        # parents_provider.
 
613
        responses = []
 
614
        transport_path = 'quack'
 
615
        repo, client = self.setup_fake_client_and_repository(
 
616
            responses, transport_path)
 
617
        graph = repo.get_graph()
 
618
        self.assertEqual(graph._parents_provider, repo)
 
619
 
 
620
 
 
621
class TestRepositoryGetParentMap(TestRemoteRepository):
 
622
 
 
623
    def test_get_parent_map_caching(self):
 
624
        # get_parent_map returns from cache until unlock()
 
625
        # setup a reponse with two revisions
 
626
        r1 = u'\u0e33'.encode('utf8')
 
627
        r2 = u'\u0dab'.encode('utf8')
 
628
        lines = [' '.join([r2, r1]), r1]
 
629
        encoded_body = bz2.compress('\n'.join(lines))
 
630
        responses = [(('ok', ), encoded_body), (('ok', ), encoded_body)]
 
631
 
 
632
        transport_path = 'quack'
 
633
        repo, client = self.setup_fake_client_and_repository(
 
634
            responses, transport_path)
 
635
        repo.lock_read()
 
636
        graph = repo.get_graph()
 
637
        parents = graph.get_parent_map([r2])
 
638
        self.assertEqual({r2: (r1,)}, parents)
 
639
        # locking and unlocking deeper should not reset
 
640
        repo.lock_read()
 
641
        repo.unlock()
 
642
        parents = graph.get_parent_map([r1])
 
643
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
 
644
        self.assertEqual(
 
645
            [('call_with_body_bytes_expecting_body',
 
646
              'Repository.get_parent_map', ('quack/', r2), '\n\n0')],
 
647
            client._calls)
 
648
        repo.unlock()
 
649
        # now we call again, and it should use the second response.
 
650
        repo.lock_read()
 
651
        graph = repo.get_graph()
 
652
        parents = graph.get_parent_map([r1])
 
653
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
 
654
        self.assertEqual(
 
655
            [('call_with_body_bytes_expecting_body',
 
656
              'Repository.get_parent_map', ('quack/', r2), '\n\n0'),
 
657
             ('call_with_body_bytes_expecting_body',
 
658
              'Repository.get_parent_map', ('quack/', r1), '\n\n0'),
 
659
            ],
 
660
            client._calls)
 
661
        repo.unlock()
 
662
 
 
663
 
541
664
class TestRepositoryGetRevisionGraph(TestRemoteRepository):
542
665
    
543
666
    def test_null_revision(self):
565
688
        result = repo.get_revision_graph()
566
689
        self.assertEqual(
567
690
            [('call_expecting_body', 'Repository.get_revision_graph',
568
 
             ('///sinhala/', ''))],
 
691
             ('sinhala/', ''))],
569
692
            client._calls)
570
693
        self.assertEqual({r1: (), r2: (r1, )}, result)
571
694
 
585
708
        result = repo.get_revision_graph(r2)
586
709
        self.assertEqual(
587
710
            [('call_expecting_body', 'Repository.get_revision_graph',
588
 
             ('///sinhala/', r2))],
 
711
             ('sinhala/', r2))],
589
712
            client._calls)
590
713
        self.assertEqual({r11: (), r12: (), r2: (r11, r12), }, result)
591
714
 
600
723
            repo.get_revision_graph, revid)
601
724
        self.assertEqual(
602
725
            [('call_expecting_body', 'Repository.get_revision_graph',
603
 
             ('///sinhala/', revid))],
 
726
             ('sinhala/', revid))],
604
727
            client._calls)
605
728
 
606
729
        
614
737
            responses, transport_path)
615
738
        result = repo.is_shared()
616
739
        self.assertEqual(
617
 
            [('call', 'Repository.is_shared', ('///quack/',))],
 
740
            [('call', 'Repository.is_shared', ('quack/',))],
618
741
            client._calls)
619
742
        self.assertEqual(True, result)
620
743
 
626
749
            responses, transport_path)
627
750
        result = repo.is_shared()
628
751
        self.assertEqual(
629
 
            [('call', 'Repository.is_shared', ('///qwack/',))],
 
752
            [('call', 'Repository.is_shared', ('qwack/',))],
630
753
            client._calls)
631
754
        self.assertEqual(False, result)
632
755
 
640
763
            responses, transport_path)
641
764
        result = repo.lock_write()
642
765
        self.assertEqual(
643
 
            [('call', 'Repository.lock_write', ('///quack/', ''))],
 
766
            [('call', 'Repository.lock_write', ('quack/', ''))],
644
767
            client._calls)
645
768
        self.assertEqual('a token', result)
646
769
 
651
774
            responses, transport_path)
652
775
        self.assertRaises(errors.LockContention, repo.lock_write)
653
776
        self.assertEqual(
654
 
            [('call', 'Repository.lock_write', ('///quack/', ''))],
 
777
            [('call', 'Repository.lock_write', ('quack/', ''))],
655
778
            client._calls)
656
779
 
657
780
    def test_lock_write_unlockable(self):
661
784
            responses, transport_path)
662
785
        self.assertRaises(errors.UnlockableTransport, repo.lock_write)
663
786
        self.assertEqual(
664
 
            [('call', 'Repository.lock_write', ('///quack/', ''))],
 
787
            [('call', 'Repository.lock_write', ('quack/', ''))],
665
788
            client._calls)
666
789
 
667
790
 
676
799
        repo.lock_write()
677
800
        repo.unlock()
678
801
        self.assertEqual(
679
 
            [('call', 'Repository.lock_write', ('///quack/', '')),
680
 
             ('call', 'Repository.unlock', ('///quack/', 'a token'))],
 
802
            [('call', 'Repository.lock_write', ('quack/', '')),
 
803
             ('call', 'Repository.unlock', ('quack/', 'a token'))],
681
804
            client._calls)
682
805
 
683
806
    def test_unlock_wrong_token(self):
701
824
            responses, transport_path)
702
825
 
703
826
        # The null revision is always there, so has_revision(None) == True.
704
 
        self.assertEqual(True, repo.has_revision(None))
 
827
        self.assertEqual(True, repo.has_revision(NULL_REVISION))
705
828
 
706
829
        # The remote repo shouldn't be accessed.
707
830
        self.assertEqual([], client._calls)
731
854
        expected_responses = [(('ok',), self.tarball_content),
732
855
            ]
733
856
        expected_calls = [('call_expecting_body', 'Repository.tarball',
734
 
                           ('///repo/', 'bz2',),),
 
857
                           ('repo/', 'bz2',),),
735
858
            ]
736
859
        remote_repo, client = self.setup_fake_client_and_repository(
737
860
            expected_responses, transport_path)
775
898
        pack_file.seek(0)
776
899
        return pack_file
777
900
 
 
901
    def make_pack_stream(self, records):
 
902
        pack_serialiser = pack.ContainerSerialiser()
 
903
        yield pack_serialiser.begin()
 
904
        for bytes, names in records:
 
905
            yield pack_serialiser.bytes_record(bytes, names)
 
906
        yield pack_serialiser.end()
 
907
 
778
908
    def test_bad_pack_from_server(self):
779
909
        """A response with invalid data (e.g. it has a record with multiple
780
910
        names) triggers an exception.
783
913
        malformed data should be.
784
914
        """
785
915
        record = ('bytes', [('name1',), ('name2',)])
786
 
        pack_file = self.make_pack_file([record])
787
 
        responses = [(('ok',), pack_file.getvalue()), ]
 
916
        pack_stream = self.make_pack_stream([record])
 
917
        responses = [(('ok',), pack_stream), ]
788
918
        transport_path = 'quack'
789
919
        repo, client = self.setup_fake_client_and_repository(
790
920
            responses, transport_path)
791
 
        stream = repo.get_data_stream(['revid'])
 
921
        search = graph.SearchResult(set(['revid']), set(), 1, set(['revid']))
 
922
        stream = repo.get_data_stream_for_search(search)
792
923
        self.assertRaises(errors.SmartProtocolError, list, stream)
793
924
    
794
925
    def test_backwards_compatibility(self):
795
926
        """If the server doesn't recognise this request, fallback to VFS."""
796
927
        error_msg = (
797
928
            "Generic bzr smart protocol error: "
798
 
            "bad request 'Repository.stream_knit_data_for_revisions'")
 
929
            "bad request 'Repository.stream_revisions_chunked'")
799
930
        responses = [
800
931
            (('error', error_msg), '')]
801
932
        repo, client = self.setup_fake_client_and_repository(
802
933
            responses, 'path')
803
934
        self.mock_called = False
804
935
        repo._real_repository = MockRealRepository(self)
805
 
        repo.get_data_stream(['revid'])
 
936
        search = graph.SearchResult(set(['revid']), set(), 1, set(['revid']))
 
937
        repo.get_data_stream_for_search(search)
806
938
        self.assertTrue(self.mock_called)
807
939
        self.failIf(client.expecting_body,
808
940
            "The protocol has been left in an unclean state that will cause "
815
947
    def __init__(self, test):
816
948
        self.test = test
817
949
 
818
 
    def get_data_stream(self, revision_ids):
819
 
        self.test.assertEqual(['revid'], revision_ids)
 
950
    def get_data_stream_for_search(self, search):
 
951
        self.test.assertEqual(set(['revid']), search.get_keys())
820
952
        self.test.mock_called = True
821
953
 
822
954