/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 breezy/plugins/git/tests/test_remote.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-13 22:54:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6968.
  • Revision ID: jelmer@jelmer.uk-20180513225428-5ysu0bs9rtk7045h
Initial work to support brz-git on python3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from __future__ import absolute_import
20
20
 
21
 
from StringIO import StringIO
 
21
from io import BytesIO
22
22
 
23
23
import os
24
24
import time
116
116
 
117
117
    def test_sprout_simple(self):
118
118
        self.remote_real.do_commit(
119
 
                message='message',
120
 
                committer='committer <committer@example.com>',
121
 
                author='author <author@example.com>')
 
119
                message=b'message',
 
120
                committer=b'committer <committer@example.com>',
 
121
                author=b'author <author@example.com>')
122
122
 
123
123
        remote = ControlDir.open(self.remote_url)
124
124
        self.make_controldir('local', format=self._to_format)
130
130
    def test_sprout_with_tags(self):
131
131
        c1 = self.remote_real.do_commit(
132
132
                message='message',
133
 
                committer='committer <committer@example.com>',
134
 
                author='author <author@example.com>')
 
133
                committer=b'committer <committer@example.com>',
 
134
                author=b'author <author@example.com>')
135
135
        c2 = self.remote_real.do_commit(
136
 
                message='another commit',
137
 
                committer='committer <committer@example.com>',
138
 
                author='author <author@example.com>',
139
 
                ref='refs/tags/another')
 
136
                message=b'another commit',
 
137
                committer=b'committer <committer@example.com>',
 
138
                author=b'author <author@example.com>',
 
139
                ref=b'refs/tags/another')
140
140
        self.remote_real.refs['refs/tags/blah'] = self.remote_real.head()
141
141
 
142
142
        remote = ControlDir.open(self.remote_url)
153
153
 
154
154
    def test_sprout_with_annotated_tag(self):
155
155
        c1 = self.remote_real.do_commit(
156
 
                message='message',
157
 
                committer='committer <committer@example.com>',
158
 
                author='author <author@example.com>')
 
156
                message=b'message',
 
157
                committer=b'committer <committer@example.com>',
 
158
                author=b'author <author@example.com>')
159
159
        c2 = self.remote_real.do_commit(
160
 
                message='another commit',
161
 
                committer='committer <committer@example.com>',
162
 
                author='author <author@example.com>',
163
 
                ref='refs/heads/another')
 
160
                message=b'another commit',
 
161
                committer=b'committer <committer@example.com>',
 
162
                author=b'author <author@example.com>',
 
163
                ref=b'refs/heads/another')
164
164
        porcelain.tag_create(
165
165
                self.remote_real,
166
 
                tag="blah",
167
 
                author='author <author@example.com>',
 
166
                tag=b"blah",
 
167
                author=b'author <author@example.com>',
168
168
                objectish=c2,
169
169
                tag_time=int(time.time()),
170
170
                tag_timezone=0,
171
171
                annotated=True,
172
 
                message="Annotated tag")
 
172
                message=b"Annotated tag")
173
173
 
174
174
        remote = ControlDir.open(self.remote_url)
175
175
        self.make_controldir('local', format=self._to_format)
223
223
        else:
224
224
            self.assertIs(None, result.new_revno)
225
225
 
226
 
        result.report(StringIO())
 
226
        result.report(BytesIO())
227
227
 
228
228
        self.assertEqual(
229
 
                {'refs/heads/newbranch': self.remote_real.refs['refs/heads/newbranch'],
 
229
                {b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
230
230
                },
231
231
                self.remote_real.get_refs())
232
232
 
233
233
    def test_push(self):
234
234
        c1 = self.remote_real.do_commit(
235
 
                message='message',
236
 
                committer='committer <committer@example.com>',
237
 
                author='author <author@example.com>')
 
235
                message=b'message',
 
236
                committer=b'committer <committer@example.com>',
 
237
                author=b'author <author@example.com>')
238
238
 
239
239
        remote = ControlDir.open(self.remote_url)
240
240
        self.make_controldir('local', format=self._from_format)
254
254
        self.assertEqual(0, result.old_revno)
255
255
        self.assertEqual(2, result.new_revno)
256
256
 
257
 
        result.report(StringIO())
 
257
        result.report(BytesIO())
258
258
 
259
259
        self.assertEqual(
260
 
                {'refs/heads/master': self.remote_real.head(),
261
 
                 'HEAD': self.remote_real.head(),
262
 
                 'refs/heads/newbranch': self.remote_real.refs['refs/heads/newbranch'],
263
 
                 'refs/tags/sometag': self.remote_real.refs['refs/heads/newbranch'],
 
260
                {b'refs/heads/master': self.remote_real.head(),
 
261
                 b'HEAD': self.remote_real.head(),
 
262
                 b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
 
263
                 b'refs/tags/sometag': self.remote_real.refs[b'refs/heads/newbranch'],
264
264
                },
265
265
                self.remote_real.get_refs())
266
266
 
267
267
    def test_push_diverged(self):
268
268
        c1 = self.remote_real.do_commit(
269
 
                message='message',
270
 
                committer='committer <committer@example.com>',
271
 
                author='author <author@example.com>',
272
 
                ref='refs/heads/newbranch')
 
269
                message=b'message',
 
270
                committer=b'committer <committer@example.com>',
 
271
                author=b'author <author@example.com>',
 
272
                ref=b'refs/heads/newbranch')
273
273
 
274
274
        remote = ControlDir.open(self.remote_url)
275
275
        wt = self.make_branch_and_tree('local', format=self._from_format)
317
317
 
318
318
    def test_remove_branch(self):
319
319
        c1 = self.remote_real.do_commit(
320
 
                message='message',
321
 
                committer='committer <committer@example.com>',
322
 
                author='author <author@example.com>')
 
320
                message=b'message',
 
321
                committer=b'committer <committer@example.com>',
 
322
                author=b'author <author@example.com>')
323
323
        c2 = self.remote_real.do_commit(
324
 
                message='another commit',
325
 
                committer='committer <committer@example.com>',
326
 
                author='author <author@example.com>',
327
 
                ref='refs/heads/blah')
 
324
                message=b'another commit',
 
325
                committer=b'committer <committer@example.com>',
 
326
                author=b'author <author@example.com>',
 
327
                ref=b'refs/heads/blah')
328
328
 
329
329
        remote = ControlDir.open(self.remote_url)
330
330
        remote.destroy_branch(name='blah')
331
331
        self.assertEqual(
332
332
                self.remote_real.get_refs(),
333
 
                {'refs/heads/master': self.remote_real.head(),
334
 
                 'HEAD': self.remote_real.head(),
 
333
                {b'refs/heads/master': self.remote_real.head(),
 
334
                 b'HEAD': self.remote_real.head(),
335
335
                })
336
336
 
337
337
    def test_list_branches(self):
338
338
        c1 = self.remote_real.do_commit(
339
 
                message='message',
340
 
                committer='committer <committer@example.com>',
341
 
                author='author <author@example.com>')
 
339
                message=b'message',
 
340
                committer=b'committer <committer@example.com>',
 
341
                author=b'author <author@example.com>')
342
342
        c2 = self.remote_real.do_commit(
343
 
                message='another commit',
344
 
                committer='committer <committer@example.com>',
345
 
                author='author <author@example.com>',
346
 
                ref='refs/heads/blah')
 
343
                message=b'another commit',
 
344
                committer=b'committer <committer@example.com>',
 
345
                author=b'author <author@example.com>',
 
346
                ref=b'refs/heads/blah')
347
347
 
348
348
        remote = ControlDir.open(self.remote_url)
349
349
        self.assertEqual(
352
352
 
353
353
    def test_get_branches(self):
354
354
        c1 = self.remote_real.do_commit(
355
 
                message='message',
356
 
                committer='committer <committer@example.com>',
357
 
                author='author <author@example.com>')
 
355
                message=b'message',
 
356
                committer=b'committer <committer@example.com>',
 
357
                author=b'author <author@example.com>')
358
358
        c2 = self.remote_real.do_commit(
359
 
                message='another commit',
360
 
                committer='committer <committer@example.com>',
361
 
                author='author <author@example.com>',
362
 
                ref='refs/heads/blah')
 
359
                message=b'another commit',
 
360
                committer=b'committer <committer@example.com>',
 
361
                author=b'author <author@example.com>',
 
362
                ref=b'refs/heads/blah')
363
363
 
364
364
        remote = ControlDir.open(self.remote_url)
365
365
        self.assertEqual(
368
368
 
369
369
    def test_remove_tag(self):
370
370
        c1 = self.remote_real.do_commit(
371
 
                message='message',
372
 
                committer='committer <committer@example.com>',
373
 
                author='author <author@example.com>')
 
371
                message=b'message',
 
372
                committer=b'committer <committer@example.com>',
 
373
                author=b'author <author@example.com>')
374
374
        c2 = self.remote_real.do_commit(
375
 
                message='another commit',
376
 
                committer='committer <committer@example.com>',
377
 
                author='author <author@example.com>',
378
 
                ref='refs/tags/blah')
 
375
                message=b'another commit',
 
376
                committer=b'committer <committer@example.com>',
 
377
                author=b'author <author@example.com>',
 
378
                ref=b'refs/tags/blah')
379
379
 
380
380
        remote = ControlDir.open(self.remote_url)
381
381
        remote_branch = remote.open_branch()
383
383
        self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah')
384
384
        self.assertEqual(
385
385
                self.remote_real.get_refs(),
386
 
                {'refs/heads/master': self.remote_real.head(),
387
 
                 'HEAD': self.remote_real.head(),
 
386
                {b'refs/heads/master': self.remote_real.head(),
 
387
                 b'HEAD': self.remote_real.head(),
388
388
                })
389
389
 
390
390
    def test_set_tag(self):
391
391
        c1 = self.remote_real.do_commit(
392
 
                message='message',
393
 
                committer='committer <committer@example.com>',
394
 
                author='author <author@example.com>')
 
392
                message=b'message',
 
393
                committer=b'committer <committer@example.com>',
 
394
                author=b'author <author@example.com>')
395
395
        c2 = self.remote_real.do_commit(
396
 
                message='another commit',
397
 
                committer='committer <committer@example.com>',
398
 
                author='author <author@example.com>')
 
396
                message=b'another commit',
 
397
                committer=b'committer <committer@example.com>',
 
398
                author=b'author <author@example.com>')
399
399
 
400
400
        remote = ControlDir.open(self.remote_url)
401
401
        remote.open_branch().tags.set_tag(
402
 
            'blah', default_mapping.revision_id_foreign_to_bzr(c1))
 
402
            b'blah', default_mapping.revision_id_foreign_to_bzr(c1))
403
403
        self.assertEqual(
404
404
                self.remote_real.get_refs(),
405
 
                {'refs/heads/master': self.remote_real.head(),
406
 
                 'refs/tags/blah': c1,
407
 
                 'HEAD': self.remote_real.head(),
 
405
                {b'refs/heads/master': self.remote_real.head(),
 
406
                 b'refs/tags/blah': c1,
 
407
                 b'HEAD': self.remote_real.head(),
408
408
                })
409
409
 
410
410
    def test_annotated_tag(self):
411
411
        c1 = self.remote_real.do_commit(
412
 
                message='message',
413
 
                committer='committer <committer@example.com>',
414
 
                author='author <author@example.com>')
 
412
                message=b'message',
 
413
                committer=b'committer <committer@example.com>',
 
414
                author=b'author <author@example.com>')
415
415
        c2 = self.remote_real.do_commit(
416
 
                message='another commit',
417
 
                committer='committer <committer@example.com>',
418
 
                author='author <author@example.com>')
 
416
                message=b'another commit',
 
417
                committer=b'committer <committer@example.com>',
 
418
                author=b'author <author@example.com>')
419
419
 
420
420
        porcelain.tag_create(
421
421
                self.remote_real,
422
 
                tag="blah",
423
 
                author='author <author@example.com>',
 
422
                tag=b"blah",
 
423
                author=b'author <author@example.com>',
424
424
                objectish=c2,
425
425
                tag_time=int(time.time()),
426
426
                tag_timezone=0,
427
427
                annotated=True,
428
 
                message="Annotated tag")
 
428
                message=b"Annotated tag")
429
429
 
430
430
        remote = ControlDir.open(self.remote_url)
431
431
        remote_branch = remote.open_branch()
432
432
        self.assertEqual({
433
 
            'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
 
433
            b'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
434
434
            remote_branch.tags.get_tag_dict())
435
435
 
436
436
    def tetst_get_branch_reference(self):
437
437
        c1 = self.remote_real.do_commit(
438
 
                message='message',
439
 
                committer='committer <committer@example.com>',
440
 
                author='author <author@example.com>')
 
438
                message=b'message',
 
439
                committer=b'committer <committer@example.com>',
 
440
                author=b'author <author@example.com>')
441
441
        c2 = self.remote_real.do_commit(
442
 
                message='another commit',
443
 
                committer='committer <committer@example.com>',
444
 
                author='author <author@example.com>')
 
442
                message=b'another commit',
 
443
                committer=b'committer <committer@example.com>',
 
444
                author=b'author <author@example.com>')
445
445
 
446
446
        remote = ControlDir.open(self.remote_url)
447
 
        self.assertEqual('refs/heads/master', remote.get_branch_reference(''))
 
447
        self.assertEqual(b'refs/heads/master', remote.get_branch_reference(''))
448
448
        self.assertEqual(None, remote.get_branch_reference('master'))