28
from StringIO import StringIO
28
from cStringIO import StringIO
32
from bzrlib import bzrdir, errors, pack, smart, tests
39
from bzrlib.branch import BranchReferenceFormat
40
import bzrlib.smart.branch
41
import bzrlib.smart.bzrdir
42
import bzrlib.smart.repository
33
43
from bzrlib.smart.request import (
34
44
FailedSmartServerResponse,
35
46
SmartServerResponse,
36
47
SuccessfulSmartServerResponse,
38
import bzrlib.smart.bzrdir
39
import bzrlib.smart.branch
40
import bzrlib.smart.repository
41
49
from bzrlib.tests import (
44
52
TestScenarioApplier,
54
from bzrlib.transport import chroot, get_transport
46
55
from bzrlib.util import bencode
81
class TestCaseWithChrootedTransport(tests.TestCaseWithTransport):
84
tests.TestCaseWithTransport.setUp(self)
85
self._chroot_server = None
87
def get_transport(self, relpath=None):
88
if self._chroot_server is None:
89
backing_transport = tests.TestCaseWithTransport.get_transport(self)
90
self._chroot_server = chroot.ChrootServer(backing_transport)
91
self._chroot_server.setUp()
92
self.addCleanup(self._chroot_server.tearDown)
93
t = get_transport(self._chroot_server.get_url())
94
if relpath is not None:
72
99
class TestCaseWithSmartMedium(tests.TestCaseWithTransport):
98
125
self.assertNotEqual(None,
99
126
SmartServerResponse(('ok', )))
102
class TestSmartServerRequestFindRepository(tests.TestCaseWithTransport):
128
def test__str__(self):
129
"""SmartServerResponses can be stringified."""
131
"<SmartServerResponse status=OK args=('args',) body='body'>",
132
str(SuccessfulSmartServerResponse(('args',), 'body')))
134
"<SmartServerResponse status=ERR args=('args',) body='body'>",
135
str(FailedSmartServerResponse(('args',), 'body')))
138
class TestSmartServerRequest(tests.TestCaseWithMemoryTransport):
140
def test_translate_client_path(self):
141
transport = self.get_transport()
142
request = SmartServerRequest(transport, 'foo/')
143
self.assertEqual('./', request.translate_client_path('foo/'))
145
errors.InvalidURLJoin, request.translate_client_path, 'foo/..')
147
errors.PathNotChild, request.translate_client_path, '/')
149
errors.PathNotChild, request.translate_client_path, 'bar/')
150
self.assertEqual('./baz', request.translate_client_path('foo/baz'))
152
def test_transport_from_client_path(self):
153
transport = self.get_transport()
154
request = SmartServerRequest(transport, 'foo/')
157
request.transport_from_client_path('foo/').base)
160
class TestSmartServerRequestFindRepository(tests.TestCaseWithMemoryTransport):
103
161
"""Tests for BzrDir.find_repository."""
105
163
def test_no_repository(self):
108
166
request = self._request_class(backing)
109
167
self.make_bzrdir('.')
110
168
self.assertEqual(SmartServerResponse(('norepository', )),
111
request.execute(backing.local_abspath('')))
113
171
def test_nonshared_repository(self):
114
172
# nonshared repositorys only allow 'find' to return a handle when the
117
175
backing = self.get_transport()
118
176
request = self._request_class(backing)
119
177
result = self._make_repository_and_result()
120
self.assertEqual(result, request.execute(backing.local_abspath('')))
178
self.assertEqual(result, request.execute(''))
121
179
self.make_bzrdir('subdir')
122
180
self.assertEqual(SmartServerResponse(('norepository', )),
123
request.execute(backing.local_abspath('subdir')))
181
request.execute('subdir'))
125
183
def _make_repository_and_result(self, shared=False, format=None):
126
184
"""Convenience function to setup a repository.
150
208
backing = self.get_transport()
151
209
request = self._request_class(backing)
152
210
result = self._make_repository_and_result(shared=True)
153
self.assertEqual(result, request.execute(backing.local_abspath('')))
211
self.assertEqual(result, request.execute(''))
154
212
self.make_bzrdir('subdir')
155
213
result2 = SmartServerResponse(result.args[0:1] + ('..', ) + result.args[2:])
156
214
self.assertEqual(result2,
157
request.execute(backing.local_abspath('subdir')))
215
request.execute('subdir'))
158
216
self.make_bzrdir('subdir/deeper')
159
217
result3 = SmartServerResponse(result.args[0:1] + ('../..', ) + result.args[2:])
160
218
self.assertEqual(result3,
161
request.execute(backing.local_abspath('subdir/deeper')))
219
request.execute('subdir/deeper'))
163
221
def test_rich_root_and_subtree_encoding(self):
164
222
"""Test for the format attributes for rich root and subtree support."""
168
226
# check the test will be valid
169
227
self.assertEqual('yes', result.args[2])
170
228
self.assertEqual('yes', result.args[3])
171
self.assertEqual(result, request.execute(backing.local_abspath('')))
229
self.assertEqual(result, request.execute(''))
173
231
def test_supports_external_lookups_no_v2(self):
174
232
"""Test for the supports_external_lookups attribute."""
177
235
result = self._make_repository_and_result(format='dirstate-with-subtree')
178
236
# check the test will be valid
179
237
self.assertEqual('no', result.args[4])
180
self.assertEqual(result, request.execute(backing.local_abspath('')))
183
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithTransport):
238
self.assertEqual(result, request.execute(''))
241
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithMemoryTransport):
185
243
def test_empty_dir(self):
186
244
"""Initializing an empty dir should succeed and do it."""
187
245
backing = self.get_transport()
188
246
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
189
247
self.assertEqual(SmartServerResponse(('ok', )),
190
request.execute(backing.local_abspath('.')))
191
249
made_dir = bzrdir.BzrDir.open_from_transport(backing)
192
250
# no branch, tree or repository is expected with the current
193
251
# default formart.
200
258
backing = self.get_transport()
201
259
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
202
260
self.assertRaises(errors.NoSuchFile,
203
request.execute, backing.local_abspath('subdir'))
261
request.execute, 'subdir')
205
263
def test_initialized_dir(self):
206
264
"""Initializing an extant bzrdir should fail like the bzrdir api."""
208
266
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
209
267
self.make_bzrdir('subdir')
210
268
self.assertRaises(errors.FileExists,
211
request.execute, backing.local_abspath('subdir'))
214
class TestSmartServerRequestOpenBranch(tests.TestCaseWithTransport):
269
request.execute, 'subdir')
272
class TestSmartServerRequestOpenBranch(TestCaseWithChrootedTransport):
216
274
def test_no_branch(self):
217
275
"""When there is no branch, ('nobranch', ) is returned."""
219
277
request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
220
278
self.make_bzrdir('.')
221
279
self.assertEqual(SmartServerResponse(('nobranch', )),
222
request.execute(backing.local_abspath('')))
224
282
def test_branch(self):
225
283
"""When there is a branch, 'ok' is returned."""
227
285
request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
228
286
self.make_branch('.')
229
287
self.assertEqual(SmartServerResponse(('ok', '')),
230
request.execute(backing.local_abspath('')))
232
290
def test_branch_reference(self):
233
291
"""When there is a branch reference, the reference URL is returned."""
235
293
request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
236
294
branch = self.make_branch('branch')
237
295
checkout = branch.create_checkout('reference',lightweight=True)
238
# TODO: once we have an API to probe for references of any sort, we
240
reference_url = backing.abspath('branch') + '/'
296
reference_url = BranchReferenceFormat().get_reference(checkout.bzrdir)
241
297
self.assertFileEqual(reference_url, 'reference/.bzr/branch/location')
242
298
self.assertEqual(SmartServerResponse(('ok', reference_url)),
243
request.execute(backing.local_abspath('reference')))
246
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithTransport):
299
request.execute('reference'))
302
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithMemoryTransport):
248
304
def test_empty(self):
249
305
"""For an empty branch, the body is empty."""
251
307
request = smart.branch.SmartServerRequestRevisionHistory(backing)
252
308
self.make_branch('.')
253
309
self.assertEqual(SmartServerResponse(('ok', ), ''),
254
request.execute(backing.local_abspath('')))
256
312
def test_not_empty(self):
257
313
"""For a non-empty branch, the body is empty."""
266
322
self.assertEqual(
267
323
SmartServerResponse(('ok', ), ('\x00'.join([r1, r2]))),
268
request.execute(backing.local_abspath('')))
271
class TestSmartServerBranchRequest(tests.TestCaseWithTransport):
327
class TestSmartServerBranchRequest(tests.TestCaseWithMemoryTransport):
273
329
def test_no_branch(self):
274
330
"""When there is a bzrdir and no branch, NotBranchError is raised."""
276
332
request = smart.branch.SmartServerBranchRequest(backing)
277
333
self.make_bzrdir('.')
278
334
self.assertRaises(errors.NotBranchError,
279
request.execute, backing.local_abspath(''))
281
337
def test_branch_reference(self):
282
338
"""When there is a branch reference, NotBranchError is raised."""
285
341
branch = self.make_branch('branch')
286
342
checkout = branch.create_checkout('reference',lightweight=True)
287
343
self.assertRaises(errors.NotBranchError,
288
request.execute, backing.local_abspath('checkout'))
291
class TestSmartServerBranchRequestLastRevisionInfo(tests.TestCaseWithTransport):
344
request.execute, 'checkout')
347
class TestSmartServerBranchRequestLastRevisionInfo(tests.TestCaseWithMemoryTransport):
293
349
def test_empty(self):
294
350
"""For an empty branch, the result is ('ok', '0', 'null:')."""
296
352
request = smart.branch.SmartServerBranchRequestLastRevisionInfo(backing)
297
353
self.make_branch('.')
298
354
self.assertEqual(SmartServerResponse(('ok', '0', 'null:')),
299
request.execute(backing.local_abspath('')))
301
357
def test_not_empty(self):
302
358
"""For a non-empty branch, the result is ('ok', 'revno', 'revid')."""
312
368
self.assertEqual(
313
369
SmartServerResponse(('ok', '2', rev_id_utf8)),
314
request.execute(backing.local_abspath('')))
317
class TestSmartServerBranchRequestGetConfigFile(tests.TestCaseWithTransport):
373
class TestSmartServerBranchRequestGetConfigFile(tests.TestCaseWithMemoryTransport):
319
375
def test_default(self):
320
376
"""With no file, we get empty content."""
324
380
# there should be no file by default
326
382
self.assertEqual(SmartServerResponse(('ok', ), content),
327
request.execute(backing.local_abspath('')))
329
385
def test_with_content(self):
330
386
# SmartServerBranchGetConfigFile should return the content from
335
391
branch = self.make_branch('.')
336
392
branch.control_files.put_utf8('branch.conf', 'foo bar baz')
337
393
self.assertEqual(SmartServerResponse(('ok', ), 'foo bar baz'),
338
request.execute(backing.local_abspath('')))
341
class TestSmartServerBranchRequestSetLastRevision(tests.TestCaseWithTransport):
397
class TestSmartServerBranchRequestSetLastRevision(tests.TestCaseWithMemoryTransport):
343
399
def test_empty(self):
344
400
backing = self.get_transport()
351
407
self.assertEqual(SmartServerResponse(('ok',)),
353
backing.local_abspath(''), branch_token, repo_token,
409
'', branch_token, repo_token,
367
423
self.assertEqual(
368
424
SmartServerResponse(('NoSuchRevision', revision_id)),
370
backing.local_abspath(''), branch_token, repo_token,
426
'', branch_token, repo_token,
389
445
self.assertEqual(
390
446
SmartServerResponse(('ok',)),
392
backing.local_abspath(''), branch_token, repo_token,
448
'', branch_token, repo_token,
394
450
self.assertEqual([rev_id_utf8], tree.branch.revision_history())
413
469
self.assertEqual(
414
470
SmartServerResponse(('ok',)),
416
backing.local_abspath(''), branch_token, repo_token,
472
'', branch_token, repo_token,
418
474
self.assertEqual([rev_id_utf8], tree.branch.revision_history())
420
476
tree.branch.unlock()
423
class TestSmartServerBranchRequestLockWrite(tests.TestCaseWithTransport):
479
class TestSmartServerBranchRequestLockWrite(tests.TestCaseWithMemoryTransport):
426
tests.TestCaseWithTransport.setUp(self)
427
self.reduceLockdirTimeout()
482
tests.TestCaseWithMemoryTransport.setUp(self)
429
484
def test_lock_write_on_unlocked_branch(self):
430
485
backing = self.get_transport()
431
486
request = smart.branch.SmartServerBranchRequestLockWrite(backing)
432
487
branch = self.make_branch('.', format='knit')
433
488
repository = branch.repository
434
response = request.execute(backing.local_abspath(''))
489
response = request.execute('')
435
490
branch_nonce = branch.control_files._lock.peek().get('nonce')
436
491
repository_nonce = repository.control_files._lock.peek().get('nonce')
437
492
self.assertEqual(
449
504
branch.lock_write()
450
505
branch.leave_lock_in_place()
452
response = request.execute(backing.local_abspath(''))
507
response = request.execute('')
453
508
self.assertEqual(
454
509
SmartServerResponse(('LockContention',)), response)
463
518
branch.leave_lock_in_place()
464
519
branch.repository.leave_lock_in_place()
466
response = request.execute(backing.local_abspath(''),
521
response = request.execute('',
467
522
branch_token, repo_token)
468
523
self.assertEqual(
469
524
SmartServerResponse(('ok', branch_token, repo_token)), response)
478
533
branch.leave_lock_in_place()
479
534
branch.repository.leave_lock_in_place()
481
response = request.execute(backing.local_abspath(''),
536
response = request.execute('',
482
537
branch_token+'xxx', repo_token)
483
538
self.assertEqual(
484
539
SmartServerResponse(('TokenMismatch',)), response)
490
545
branch.repository.lock_write()
491
546
branch.repository.leave_lock_in_place()
492
547
branch.repository.unlock()
493
response = request.execute(backing.local_abspath(''))
548
response = request.execute('')
494
549
self.assertEqual(
495
550
SmartServerResponse(('LockContention',)), response)
498
553
backing = self.get_readonly_transport()
499
554
request = smart.branch.SmartServerBranchRequestLockWrite(backing)
500
555
branch = self.make_branch('.')
501
response = request.execute('')
556
root = self.get_transport().clone('/')
557
path = urlutils.relative_url(root.base, self.get_transport().base)
558
response = request.execute(path)
502
559
error_name, lock_str, why_str = response.args
503
560
self.assertFalse(response.is_successful())
504
561
self.assertEqual('LockFailed', error_name)
507
class TestSmartServerBranchRequestUnlock(tests.TestCaseWithTransport):
564
class TestSmartServerBranchRequestUnlock(tests.TestCaseWithMemoryTransport):
510
tests.TestCaseWithTransport.setUp(self)
511
self.reduceLockdirTimeout()
567
tests.TestCaseWithMemoryTransport.setUp(self)
513
569
def test_unlock_on_locked_branch_and_repo(self):
514
570
backing = self.get_transport()
523
579
branch.leave_lock_in_place()
524
580
branch.repository.leave_lock_in_place()
526
response = request.execute(backing.local_abspath(''),
582
response = request.execute('',
527
583
branch_token, repo_token)
528
584
self.assertEqual(
529
585
SmartServerResponse(('ok',)), response)
538
594
request = smart.branch.SmartServerBranchRequestUnlock(backing)
539
595
branch = self.make_branch('.', format='knit')
540
596
response = request.execute(
541
backing.local_abspath(''), 'branch token', 'repo token')
597
'', 'branch token', 'repo token')
542
598
self.assertEqual(
543
599
SmartServerResponse(('TokenMismatch',)), response)
553
609
# Issue branch lock_write request on the unlocked branch (with locked
555
611
response = request.execute(
556
backing.local_abspath(''), 'branch token', repo_token)
612
'', 'branch token', repo_token)
557
613
self.assertEqual(
558
614
SmartServerResponse(('TokenMismatch',)), response)
561
class TestSmartServerRepositoryRequest(tests.TestCaseWithTransport):
617
class TestSmartServerRepositoryRequest(tests.TestCaseWithMemoryTransport):
563
619
def test_no_repository(self):
564
620
"""Raise NoRepositoryPresent when there is a bzrdir and no repo."""
571
627
self.make_repository('.', shared=True)
572
628
self.make_bzrdir('subdir')
573
629
self.assertRaises(errors.NoRepositoryPresent,
574
request.execute, backing.local_abspath('subdir'))
630
request.execute, 'subdir')
577
633
class TestSmartServerRepositoryGetParentMap(tests.TestCaseWithTransport):
583
639
tree = self.make_branch_and_memory_tree('.')
585
641
self.assertEqual(None,
586
request.execute(backing.local_abspath(''), 'missing-id'))
642
request.execute('', 'missing-id'))
587
643
# Note that it returns a body (of '' bzipped).
588
644
self.assertEqual(
589
645
SuccessfulSmartServerResponse(('ok', ), bz2.compress('')),
590
646
request.do_body('\n\n0\n'))
593
class TestSmartServerRepositoryGetRevisionGraph(tests.TestCaseWithTransport):
649
class TestSmartServerRepositoryGetRevisionGraph(tests.TestCaseWithMemoryTransport):
595
651
def test_none_argument(self):
596
652
backing = self.get_transport()
605
661
# the lines of revision_id->revision_parent_list has no guaranteed
606
662
# order coming out of a dict, so sort both our test and response
607
663
lines = sorted([' '.join([r2, r1]), r1])
608
response = request.execute(backing.local_abspath(''), '')
664
response = request.execute('', '')
609
665
response.body = '\n'.join(sorted(response.body.split('\n')))
611
667
self.assertEqual(
625
681
self.assertEqual(SmartServerResponse(('ok', ), rev_id_utf8),
626
request.execute(backing.local_abspath(''), rev_id_utf8))
682
request.execute('', rev_id_utf8))
628
684
def test_no_such_revision(self):
629
685
backing = self.get_transport()
637
693
# Note that it still returns body (of zero bytes).
638
694
self.assertEqual(
639
695
SmartServerResponse(('nosuchrevision', 'missingrevision', ), ''),
640
request.execute(backing.local_abspath(''), 'missingrevision'))
643
class TestSmartServerRequestHasRevision(tests.TestCaseWithTransport):
696
request.execute('', 'missingrevision'))
699
class TestSmartServerRequestHasRevision(tests.TestCaseWithMemoryTransport):
645
701
def test_missing_revision(self):
646
702
"""For a missing revision, ('no', ) is returned."""
648
704
request = smart.repository.SmartServerRequestHasRevision(backing)
649
705
self.make_repository('.')
650
706
self.assertEqual(SmartServerResponse(('no', )),
651
request.execute(backing.local_abspath(''), 'revid'))
707
request.execute('', 'revid'))
653
709
def test_present_revision(self):
654
710
"""For a present revision, ('yes', ) is returned."""
663
719
self.assertTrue(tree.branch.repository.has_revision(rev_id_utf8))
664
720
self.assertEqual(SmartServerResponse(('yes', )),
665
request.execute(backing.local_abspath(''), rev_id_utf8))
668
class TestSmartServerRepositoryGatherStats(tests.TestCaseWithTransport):
721
request.execute('', rev_id_utf8))
724
class TestSmartServerRepositoryGatherStats(tests.TestCaseWithMemoryTransport):
670
726
def test_empty_revid(self):
671
727
"""With an empty revid, we get only size an number and revisions"""
676
732
size = stats['size']
677
733
expected_body = 'revisions: 0\nsize: %d\n' % size
678
734
self.assertEqual(SmartServerResponse(('ok', ), expected_body),
679
request.execute(backing.local_abspath(''), '', 'no'))
735
request.execute('', '', 'no'))
681
737
def test_revid_with_committers(self):
682
738
"""For a revid we get more infos."""
700
756
'size: %d\n' % size)
701
757
self.assertEqual(SmartServerResponse(('ok', ), expected_body),
702
request.execute(backing.local_abspath(''),
703
759
rev_id_utf8, 'no'))
705
761
def test_not_empty_repository_with_committers(self):
726
782
'size: %d\n' % size)
727
783
self.assertEqual(SmartServerResponse(('ok', ), expected_body),
728
request.execute(backing.local_abspath(''),
729
785
rev_id_utf8, 'yes'))
732
class TestSmartServerRepositoryIsShared(tests.TestCaseWithTransport):
788
class TestSmartServerRepositoryIsShared(tests.TestCaseWithMemoryTransport):
734
790
def test_is_shared(self):
735
791
"""For a shared repository, ('yes', ) is returned."""
737
793
request = smart.repository.SmartServerRepositoryIsShared(backing)
738
794
self.make_repository('.', shared=True)
739
795
self.assertEqual(SmartServerResponse(('yes', )),
740
request.execute(backing.local_abspath(''), ))
796
request.execute('', ))
742
798
def test_is_not_shared(self):
743
799
"""For a shared repository, ('no', ) is returned."""
745
801
request = smart.repository.SmartServerRepositoryIsShared(backing)
746
802
self.make_repository('.', shared=False)
747
803
self.assertEqual(SmartServerResponse(('no', )),
748
request.execute(backing.local_abspath(''), ))
751
class TestSmartServerRepositoryLockWrite(tests.TestCaseWithTransport):
804
request.execute('', ))
807
class TestSmartServerRepositoryLockWrite(tests.TestCaseWithMemoryTransport):
754
tests.TestCaseWithTransport.setUp(self)
755
self.reduceLockdirTimeout()
810
tests.TestCaseWithMemoryTransport.setUp(self)
757
812
def test_lock_write_on_unlocked_repo(self):
758
813
backing = self.get_transport()
759
814
request = smart.repository.SmartServerRepositoryLockWrite(backing)
760
815
repository = self.make_repository('.', format='knit')
761
response = request.execute(backing.local_abspath(''))
816
response = request.execute('')
762
817
nonce = repository.control_files._lock.peek().get('nonce')
763
818
self.assertEqual(SmartServerResponse(('ok', nonce)), response)
764
819
# The repository is now locked. Verify that with a new repository
773
828
repository.lock_write()
774
829
repository.leave_lock_in_place()
775
830
repository.unlock()
776
response = request.execute(backing.local_abspath(''))
831
response = request.execute('')
777
832
self.assertEqual(
778
833
SmartServerResponse(('LockContention',)), response)
786
841
self.assertEqual('LockFailed', response.args[0])
789
class TestSmartServerRepositoryUnlock(tests.TestCaseWithTransport):
844
class TestSmartServerRepositoryUnlock(tests.TestCaseWithMemoryTransport):
792
tests.TestCaseWithTransport.setUp(self)
793
self.reduceLockdirTimeout()
847
tests.TestCaseWithMemoryTransport.setUp(self)
795
849
def test_unlock_on_locked_repo(self):
796
850
backing = self.get_transport()
799
853
token = repository.lock_write()
800
854
repository.leave_lock_in_place()
801
855
repository.unlock()
802
response = request.execute(backing.local_abspath(''), token)
856
response = request.execute('', token)
803
857
self.assertEqual(
804
858
SmartServerResponse(('ok',)), response)
805
859
# The repository is now unlocked. Verify that with a new repository
812
866
backing = self.get_transport()
813
867
request = smart.repository.SmartServerRepositoryUnlock(backing)
814
868
repository = self.make_repository('.', format='knit')
815
response = request.execute(backing.local_abspath(''), 'some token')
869
response = request.execute('', 'some token')
816
870
self.assertEqual(
817
871
SmartServerResponse(('TokenMismatch',)), response)
826
880
# make some extraneous junk in the repository directory which should
828
882
self.build_tree(['.bzr/repository/extra-junk'])
829
response = request.execute(backing.local_abspath(''), 'bz2')
883
response = request.execute('', 'bz2')
830
884
self.assertEqual(('ok',), response.args)
831
885
# body should be a tbz2
832
886
body_file = StringIO(response.body)
841
895
"extraneous file present in tar file")
844
class TestSmartServerRepositoryStreamKnitData(tests.TestCaseWithTransport):
898
class TestSmartServerRepositoryStreamKnitData(tests.TestCaseWithMemoryTransport):
846
900
def test_fetch_revisions(self):
847
901
backing = self.get_transport()
855
909
r1 = tree.commit('2nd commit', rev_id=rev_id2_utf8)
858
response = request.execute(backing.local_abspath(''), rev_id2_utf8)
912
response = request.execute('', rev_id2_utf8)
859
913
self.assertEqual(('ok',), response.args)
860
from cStringIO import StringIO
861
914
unpacker = pack.ContainerReader(StringIO(response.body))
863
916
for [name], read_bytes in unpacker.iter_records():
873
926
request = smart.repository.SmartServerRepositoryStreamKnitDataForRevisions(backing)
874
927
repo = self.make_repository('.')
875
928
rev_id1_utf8 = u'\xc8'.encode('utf-8')
876
response = request.execute(backing.local_abspath(''), rev_id1_utf8)
929
response = request.execute('', rev_id1_utf8)
877
930
self.assertEqual(
878
931
SmartServerResponse(('NoSuchRevision', rev_id1_utf8)),
882
class TestSmartServerRepositoryStreamRevisionsChunked(tests.TestCaseWithTransport):
935
class TestSmartServerRepositoryStreamRevisionsChunked(tests.TestCaseWithMemoryTransport):
884
937
def test_fetch_revisions(self):
885
938
backing = self.get_transport()
894
947
tree.commit('2nd commit', rev_id=rev_id2_utf8)
897
response = request.execute(backing.local_abspath(''))
950
response = request.execute('')
898
951
self.assertEqual(None, response)
899
952
response = request.do_body("%s\n%s\n1" % (rev_id2_utf8, rev_id1_utf8))
900
953
self.assertEqual(('ok',), response.args)
901
from cStringIO import StringIO
902
954
parser = pack.ContainerPushParser()
904
956
for stream_bytes in response.body_stream:
917
969
repo = self.make_repository('.')
918
970
rev_id1_utf8 = u'\xc8'.encode('utf-8')
919
response = request.execute(backing.local_abspath(''))
971
response = request.execute('')
920
972
self.assertEqual(None, response)
921
973
response = request.do_body("%s\n\n1" % (rev_id1_utf8,))
922
974
self.assertEqual(