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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
from ...controldir import ControlDir
27
27
from ...errors import (
28
 
    BzrError,
29
28
    DivergedBranches,
30
29
    NotBranchError,
31
30
    NoSuchTag,
55
54
 
56
55
    def test_simple(self):
57
56
        self.assertEqual(("foo", None, None, "/bar"),
58
 
            split_git_url("git://foo/bar"))
 
57
                         split_git_url("git://foo/bar"))
59
58
 
60
59
    def test_port(self):
61
60
        self.assertEqual(("foo", 343, None, "/bar"),
62
 
            split_git_url("git://foo:343/bar"))
 
61
                         split_git_url("git://foo:343/bar"))
63
62
 
64
63
    def test_username(self):
65
64
        self.assertEqual(("foo", None, "la", "/bar"),
66
 
            split_git_url("git://la@foo/bar"))
 
65
                         split_git_url("git://la@foo/bar"))
67
66
 
68
67
    def test_nopath(self):
69
68
        self.assertEqual(("foo", None, None, "/"),
70
 
            split_git_url("git://foo/"))
 
69
                         split_git_url("git://foo/"))
71
70
 
72
71
    def test_slashpath(self):
73
72
        self.assertEqual(("foo", None, None, "//bar"),
74
 
            split_git_url("git://foo//bar"))
 
73
                         split_git_url("git://foo//bar"))
75
74
 
76
75
    def test_homedir(self):
77
76
        self.assertEqual(("foo", None, None, "~bar"),
78
 
            split_git_url("git://foo/~bar"))
 
77
                         split_git_url("git://foo/~bar"))
79
78
 
80
79
 
81
80
class ParseGitErrorTests(TestCase):
96
95
        e = parse_git_error("url", "Repository not found.\n")
97
96
        self.assertIsInstance(e, NotBranchError)
98
97
 
 
98
    def test_notbrancherror_normal(self):
 
99
        e = parse_git_error(
 
100
            "url", "fatal: '/srv/git/lintian-brush' does not appear to be a git repository")
 
101
        self.assertIsInstance(e, NotBranchError)
 
102
 
99
103
    def test_head_update(self):
100
104
        e = parse_git_error("url", "HEAD failed to update\n")
101
105
        self.assertIsInstance(e, HeadUpdateFailed)
106
110
            "access denied or repository not exported: /debian/altermime.git")
107
111
        self.assertIsInstance(e, PermissionDenied)
108
112
 
 
113
    def test_permission_denied_gitlab(self):
 
114
        e = parse_git_error(
 
115
            "url",
 
116
            'GitLab: You are not allowed to push code to this project.\n')
 
117
        self.assertIsInstance(e, PermissionDenied)
 
118
 
 
119
    def test_permission_denied_github(self):
 
120
        e = parse_git_error(
 
121
            "url",
 
122
            'Permission to porridge/gaduhistory.git denied to jelmer.')
 
123
        self.assertIsInstance(e, PermissionDenied)
 
124
        self.assertEqual(e.path, 'porridge/gaduhistory.git')
 
125
        self.assertEqual(e.extra, ': denied to jelmer')
 
126
 
109
127
 
110
128
class TestRemoteGitBranchFormat(TestCase):
111
129
 
114
132
        self.format = RemoteGitBranchFormat()
115
133
 
116
134
    def test_get_format_description(self):
117
 
        self.assertEqual("Remote Git Branch", self.format.get_format_description())
 
135
        self.assertEqual("Remote Git Branch",
 
136
                         self.format.get_format_description())
118
137
 
119
138
    def test_get_network_name(self):
120
139
        self.assertEqual(b"git", self.format.network_name())
123
142
        self.assertTrue(self.format.supports_tags())
124
143
 
125
144
 
 
145
class TestRemoteGitBranch(TestCaseWithTransport):
 
146
 
 
147
    def setUp(self):
 
148
        TestCaseWithTransport.setUp(self)
 
149
        self.remote_real = GitRepo.init('remote', mkdir=True)
 
150
        self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
 
151
        self.permit_url(self.remote_url)
 
152
 
 
153
    def test_set_last_revision_info(self):
 
154
        c1 = self.remote_real.do_commit(
 
155
            message=b'message 1',
 
156
            committer=b'committer <committer@example.com>',
 
157
            author=b'author <author@example.com>',
 
158
            ref=b'refs/heads/newbranch')
 
159
        c2 = self.remote_real.do_commit(
 
160
            message=b'message 2',
 
161
            committer=b'committer <committer@example.com>',
 
162
            author=b'author <author@example.com>',
 
163
            ref=b'refs/heads/newbranch')
 
164
 
 
165
        remote = ControlDir.open(self.remote_url)
 
166
        newbranch = remote.open_branch('newbranch')
 
167
        self.assertEqual(newbranch.lookup_foreign_revision_id(c2),
 
168
                         newbranch.last_revision())
 
169
        newbranch.set_last_revision_info(
 
170
            1, newbranch.lookup_foreign_revision_id(c1))
 
171
        self.assertEqual(c1, self.remote_real.refs[b'refs/heads/newbranch'])
 
172
        self.assertEqual(newbranch.last_revision(),
 
173
                         newbranch.lookup_foreign_revision_id(c1))
 
174
 
 
175
 
126
176
class FetchFromRemoteTestBase(object):
127
177
 
128
178
    _test_needs_features = [ExecutableFeature('git')]
137
187
 
138
188
    def test_sprout_simple(self):
139
189
        self.remote_real.do_commit(
140
 
                message=b'message',
141
 
                committer=b'committer <committer@example.com>',
142
 
                author=b'author <author@example.com>')
 
190
            message=b'message',
 
191
            committer=b'committer <committer@example.com>',
 
192
            author=b'author <author@example.com>')
143
193
 
144
194
        remote = ControlDir.open(self.remote_url)
145
195
        self.make_controldir('local', format=self._to_format)
146
196
        local = remote.sprout('local')
147
197
        self.assertEqual(
148
 
                default_mapping.revision_id_foreign_to_bzr(self.remote_real.head()),
149
 
                local.open_branch().last_revision())
 
198
            default_mapping.revision_id_foreign_to_bzr(
 
199
                self.remote_real.head()),
 
200
            local.open_branch().last_revision())
150
201
 
151
202
    def test_sprout_with_tags(self):
152
203
        c1 = self.remote_real.do_commit(
153
 
                message=b'message',
154
 
                committer=b'committer <committer@example.com>',
155
 
                author=b'author <author@example.com>')
 
204
            message=b'message',
 
205
            committer=b'committer <committer@example.com>',
 
206
            author=b'author <author@example.com>')
156
207
        c2 = self.remote_real.do_commit(
157
 
                message=b'another commit',
158
 
                committer=b'committer <committer@example.com>',
159
 
                author=b'author <author@example.com>',
160
 
                ref=b'refs/tags/another')
 
208
            message=b'another commit',
 
209
            committer=b'committer <committer@example.com>',
 
210
            author=b'author <author@example.com>',
 
211
            ref=b'refs/tags/another')
161
212
        self.remote_real.refs[b'refs/tags/blah'] = self.remote_real.head()
162
213
 
163
214
        remote = ControlDir.open(self.remote_url)
165
216
        local = remote.sprout('local')
166
217
        local_branch = local.open_branch()
167
218
        self.assertEqual(
168
 
                default_mapping.revision_id_foreign_to_bzr(c1),
169
 
                local_branch.last_revision())
 
219
            default_mapping.revision_id_foreign_to_bzr(c1),
 
220
            local_branch.last_revision())
170
221
        self.assertEqual(
171
 
                {'blah': local_branch.last_revision(),
172
 
                 'another': default_mapping.revision_id_foreign_to_bzr(c2)},
173
 
                local_branch.tags.get_tag_dict())
 
222
            {'blah': local_branch.last_revision(),
 
223
             'another': default_mapping.revision_id_foreign_to_bzr(c2)},
 
224
            local_branch.tags.get_tag_dict())
174
225
 
175
226
    def test_sprout_with_annotated_tag(self):
176
227
        c1 = self.remote_real.do_commit(
177
 
                message=b'message',
178
 
                committer=b'committer <committer@example.com>',
179
 
                author=b'author <author@example.com>')
180
 
        c2 = self.remote_real.do_commit(
181
 
                message=b'another commit',
182
 
                committer=b'committer <committer@example.com>',
183
 
                author=b'author <author@example.com>',
184
 
                ref=b'refs/heads/another')
185
 
        porcelain.tag_create(
186
 
                self.remote_real,
187
 
                tag=b"blah",
188
 
                author=b'author <author@example.com>',
189
 
                objectish=c2,
190
 
                tag_time=int(time.time()),
191
 
                tag_timezone=0,
192
 
                annotated=True,
193
 
                message=b"Annotated tag")
194
 
 
195
 
        remote = ControlDir.open(self.remote_url)
196
 
        self.make_controldir('local', format=self._to_format)
197
 
        local = remote.sprout('local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
198
 
        local_branch = local.open_branch()
199
 
        self.assertEqual(
200
 
                default_mapping.revision_id_foreign_to_bzr(c1),
201
 
                local_branch.last_revision())
202
 
        self.assertEqual(
203
 
                {'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
204
 
                local_branch.tags.get_tag_dict())
205
 
 
206
 
 
207
 
class FetchFromRemoteToBzrTests(FetchFromRemoteTestBase,TestCaseWithTransport):
 
228
            message=b'message',
 
229
            committer=b'committer <committer@example.com>',
 
230
            author=b'author <author@example.com>')
 
231
        c2 = self.remote_real.do_commit(
 
232
            message=b'another commit',
 
233
            committer=b'committer <committer@example.com>',
 
234
            author=b'author <author@example.com>',
 
235
            ref=b'refs/heads/another')
 
236
        porcelain.tag_create(
 
237
            self.remote_real,
 
238
            tag=b"blah",
 
239
            author=b'author <author@example.com>',
 
240
            objectish=c2,
 
241
            tag_time=int(time.time()),
 
242
            tag_timezone=0,
 
243
            annotated=True,
 
244
            message=b"Annotated tag")
 
245
 
 
246
        remote = ControlDir.open(self.remote_url)
 
247
        self.make_controldir('local', format=self._to_format)
 
248
        local = remote.sprout(
 
249
            'local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
 
250
        local_branch = local.open_branch()
 
251
        self.assertEqual(
 
252
            default_mapping.revision_id_foreign_to_bzr(c1),
 
253
            local_branch.last_revision())
 
254
        self.assertEqual(
 
255
            {'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
 
256
            local_branch.tags.get_tag_dict())
 
257
 
 
258
    def test_sprout_with_annotated_tag_unreferenced(self):
 
259
        c1 = self.remote_real.do_commit(
 
260
            message=b'message',
 
261
            committer=b'committer <committer@example.com>',
 
262
            author=b'author <author@example.com>')
 
263
        c2 = self.remote_real.do_commit(
 
264
            message=b'another commit',
 
265
            committer=b'committer <committer@example.com>',
 
266
            author=b'author <author@example.com>')
 
267
        porcelain.tag_create(
 
268
            self.remote_real,
 
269
            tag=b"blah",
 
270
            author=b'author <author@example.com>',
 
271
            objectish=c1,
 
272
            tag_time=int(time.time()),
 
273
            tag_timezone=0,
 
274
            annotated=True,
 
275
            message=b"Annotated tag")
 
276
 
 
277
        remote = ControlDir.open(self.remote_url)
 
278
        self.make_controldir('local', format=self._to_format)
 
279
        local = remote.sprout(
 
280
            'local',
 
281
            revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
 
282
        local_branch = local.open_branch()
 
283
        self.assertEqual(
 
284
            default_mapping.revision_id_foreign_to_bzr(c1),
 
285
            local_branch.last_revision())
 
286
        self.assertEqual(
 
287
            {'blah': default_mapping.revision_id_foreign_to_bzr(c1)},
 
288
            local_branch.tags.get_tag_dict())
 
289
 
 
290
 
 
291
class FetchFromRemoteToBzrTests(FetchFromRemoteTestBase, TestCaseWithTransport):
208
292
 
209
293
    _to_format = '2a'
210
294
 
211
295
 
212
 
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase,TestCaseWithTransport):
 
296
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase, TestCaseWithTransport):
213
297
 
214
298
    _to_format = 'git'
215
299
 
236
320
        if self._from_format == 'git':
237
321
            result = remote.push_branch(wt.branch, name='newbranch')
238
322
        else:
239
 
            result = remote.push_branch(wt.branch, lossy=True, name='newbranch')
 
323
            result = remote.push_branch(
 
324
                wt.branch, lossy=True, name='newbranch')
240
325
 
241
326
        self.assertEqual(0, result.old_revno)
242
327
        if self._from_format == 'git':
247
332
        result.report(BytesIO())
248
333
 
249
334
        self.assertEqual(
250
 
                {b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
251
 
                },
252
 
                self.remote_real.get_refs())
 
335
            {b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
 
336
             },
 
337
            self.remote_real.get_refs())
253
338
 
254
339
    def test_push(self):
255
340
        c1 = self.remote_real.do_commit(
256
 
                message=b'message',
257
 
                committer=b'committer <committer@example.com>',
258
 
                author=b'author <author@example.com>')
 
341
            message=b'message',
 
342
            committer=b'committer <committer@example.com>',
 
343
            author=b'author <author@example.com>')
259
344
 
260
345
        remote = ControlDir.open(self.remote_url)
261
346
        self.make_controldir('local', format=self._from_format)
270
355
        if self._from_format == 'git':
271
356
            result = wt.branch.push(remote.create_branch('newbranch'))
272
357
        else:
273
 
            result = wt.branch.push(remote.create_branch('newbranch'), lossy=True)
 
358
            result = wt.branch.push(
 
359
                remote.create_branch('newbranch'), lossy=True)
274
360
 
275
361
        self.assertEqual(0, result.old_revno)
276
362
        self.assertEqual(2, result.new_revno)
278
364
        result.report(BytesIO())
279
365
 
280
366
        self.assertEqual(
281
 
                {b'refs/heads/master': self.remote_real.head(),
282
 
                 b'HEAD': self.remote_real.head(),
283
 
                 b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
284
 
                 b'refs/tags/sometag': self.remote_real.refs[b'refs/heads/newbranch'],
285
 
                },
286
 
                self.remote_real.get_refs())
 
367
            {b'refs/heads/master': self.remote_real.head(),
 
368
             b'HEAD': self.remote_real.head(),
 
369
             b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
 
370
             b'refs/tags/sometag': self.remote_real.refs[b'refs/heads/newbranch'],
 
371
             },
 
372
            self.remote_real.get_refs())
287
373
 
288
374
    def test_push_diverged(self):
289
375
        c1 = self.remote_real.do_commit(
290
 
                message=b'message',
291
 
                committer=b'committer <committer@example.com>',
292
 
                author=b'author <author@example.com>',
293
 
                ref=b'refs/heads/newbranch')
 
376
            message=b'message',
 
377
            committer=b'committer <committer@example.com>',
 
378
            author=b'author <author@example.com>',
 
379
            ref=b'refs/heads/newbranch')
294
380
 
295
381
        remote = ControlDir.open(self.remote_url)
296
382
        wt = self.make_branch_and_tree('local', format=self._from_format)
302
388
        if self._from_format == 'git':
303
389
            self.assertRaises(DivergedBranches, wt.branch.push, newbranch)
304
390
        else:
305
 
            self.assertRaises(DivergedBranches, wt.branch.push, newbranch, lossy=True)
 
391
            self.assertRaises(DivergedBranches, wt.branch.push,
 
392
                              newbranch, lossy=True)
306
393
 
307
394
        self.assertEqual(
308
 
                {b'refs/heads/newbranch': c1 },
309
 
                self.remote_real.get_refs())
 
395
            {b'refs/heads/newbranch': c1},
 
396
            self.remote_real.get_refs())
310
397
 
311
398
        if self._from_format == 'git':
312
399
            wt.branch.push(newbranch, overwrite=True)
316
403
        self.assertNotEqual(c1, self.remote_real.refs[b'refs/heads/newbranch'])
317
404
 
318
405
 
319
 
class PushToRemoteFromBzrTests(PushToRemoteBase,TestCaseWithTransport):
 
406
class PushToRemoteFromBzrTests(PushToRemoteBase, TestCaseWithTransport):
320
407
 
321
408
    _from_format = '2a'
322
409
 
323
410
 
324
 
class PushToRemoteFromGitTests(PushToRemoteBase,TestCaseWithTransport):
 
411
class PushToRemoteFromGitTests(PushToRemoteBase, TestCaseWithTransport):
325
412
 
326
413
    _from_format = 'git'
327
414
 
338
425
 
339
426
    def test_remove_branch(self):
340
427
        c1 = self.remote_real.do_commit(
341
 
                message=b'message',
342
 
                committer=b'committer <committer@example.com>',
343
 
                author=b'author <author@example.com>')
 
428
            message=b'message',
 
429
            committer=b'committer <committer@example.com>',
 
430
            author=b'author <author@example.com>')
344
431
        c2 = self.remote_real.do_commit(
345
 
                message=b'another commit',
346
 
                committer=b'committer <committer@example.com>',
347
 
                author=b'author <author@example.com>',
348
 
                ref=b'refs/heads/blah')
 
432
            message=b'another commit',
 
433
            committer=b'committer <committer@example.com>',
 
434
            author=b'author <author@example.com>',
 
435
            ref=b'refs/heads/blah')
349
436
 
350
437
        remote = ControlDir.open(self.remote_url)
351
438
        remote.destroy_branch(name='blah')
352
439
        self.assertEqual(
353
 
                self.remote_real.get_refs(),
354
 
                {b'refs/heads/master': self.remote_real.head(),
355
 
                 b'HEAD': self.remote_real.head(),
356
 
                })
 
440
            self.remote_real.get_refs(),
 
441
            {b'refs/heads/master': self.remote_real.head(),
 
442
             b'HEAD': self.remote_real.head(),
 
443
             })
357
444
 
358
445
    def test_list_branches(self):
359
446
        c1 = self.remote_real.do_commit(
360
 
                message=b'message',
361
 
                committer=b'committer <committer@example.com>',
362
 
                author=b'author <author@example.com>')
 
447
            message=b'message',
 
448
            committer=b'committer <committer@example.com>',
 
449
            author=b'author <author@example.com>')
363
450
        c2 = self.remote_real.do_commit(
364
 
                message=b'another commit',
365
 
                committer=b'committer <committer@example.com>',
366
 
                author=b'author <author@example.com>',
367
 
                ref=b'refs/heads/blah')
 
451
            message=b'another commit',
 
452
            committer=b'committer <committer@example.com>',
 
453
            author=b'author <author@example.com>',
 
454
            ref=b'refs/heads/blah')
368
455
 
369
456
        remote = ControlDir.open(self.remote_url)
370
457
        self.assertEqual(
371
 
                set(['master', 'blah', 'master']),
372
 
                set([b.name for b in remote.list_branches()]))
 
458
            set(['master', 'blah', 'master']),
 
459
            set([b.name for b in remote.list_branches()]))
373
460
 
374
461
    def test_get_branches(self):
375
462
        c1 = self.remote_real.do_commit(
376
 
                message=b'message',
377
 
                committer=b'committer <committer@example.com>',
378
 
                author=b'author <author@example.com>')
 
463
            message=b'message',
 
464
            committer=b'committer <committer@example.com>',
 
465
            author=b'author <author@example.com>')
379
466
        c2 = self.remote_real.do_commit(
380
 
                message=b'another commit',
381
 
                committer=b'committer <committer@example.com>',
382
 
                author=b'author <author@example.com>',
383
 
                ref=b'refs/heads/blah')
 
467
            message=b'another commit',
 
468
            committer=b'committer <committer@example.com>',
 
469
            author=b'author <author@example.com>',
 
470
            ref=b'refs/heads/blah')
384
471
 
385
472
        remote = ControlDir.open(self.remote_url)
386
473
        self.assertEqual(
387
 
                {'': 'master', 'blah': 'blah', 'master': 'master'},
388
 
                {n: b.name for (n, b) in remote.get_branches().items()})
 
474
            {'': 'master', 'blah': 'blah', 'master': 'master'},
 
475
            {n: b.name for (n, b) in remote.get_branches().items()})
389
476
 
390
477
    def test_remove_tag(self):
391
478
        c1 = self.remote_real.do_commit(
392
 
                message=b'message',
393
 
                committer=b'committer <committer@example.com>',
394
 
                author=b'author <author@example.com>')
 
479
            message=b'message',
 
480
            committer=b'committer <committer@example.com>',
 
481
            author=b'author <author@example.com>')
395
482
        c2 = self.remote_real.do_commit(
396
 
                message=b'another commit',
397
 
                committer=b'committer <committer@example.com>',
398
 
                author=b'author <author@example.com>',
399
 
                ref=b'refs/tags/blah')
 
483
            message=b'another commit',
 
484
            committer=b'committer <committer@example.com>',
 
485
            author=b'author <author@example.com>',
 
486
            ref=b'refs/tags/blah')
400
487
 
401
488
        remote = ControlDir.open(self.remote_url)
402
489
        remote_branch = remote.open_branch()
403
490
        remote_branch.tags.delete_tag('blah')
404
491
        self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah')
405
492
        self.assertEqual(
406
 
                self.remote_real.get_refs(),
407
 
                {b'refs/heads/master': self.remote_real.head(),
408
 
                 b'HEAD': self.remote_real.head(),
409
 
                })
 
493
            self.remote_real.get_refs(),
 
494
            {b'refs/heads/master': self.remote_real.head(),
 
495
             b'HEAD': self.remote_real.head(),
 
496
             })
410
497
 
411
498
    def test_set_tag(self):
412
499
        c1 = self.remote_real.do_commit(
413
 
                message=b'message',
414
 
                committer=b'committer <committer@example.com>',
415
 
                author=b'author <author@example.com>')
 
500
            message=b'message',
 
501
            committer=b'committer <committer@example.com>',
 
502
            author=b'author <author@example.com>')
416
503
        c2 = self.remote_real.do_commit(
417
 
                message=b'another commit',
418
 
                committer=b'committer <committer@example.com>',
419
 
                author=b'author <author@example.com>')
 
504
            message=b'another commit',
 
505
            committer=b'committer <committer@example.com>',
 
506
            author=b'author <author@example.com>')
420
507
 
421
508
        remote = ControlDir.open(self.remote_url)
422
509
        remote.open_branch().tags.set_tag(
423
510
            b'blah', default_mapping.revision_id_foreign_to_bzr(c1))
424
511
        self.assertEqual(
425
 
                self.remote_real.get_refs(),
426
 
                {b'refs/heads/master': self.remote_real.head(),
427
 
                 b'refs/tags/blah': c1,
428
 
                 b'HEAD': self.remote_real.head(),
429
 
                })
 
512
            self.remote_real.get_refs(),
 
513
            {b'refs/heads/master': self.remote_real.head(),
 
514
             b'refs/tags/blah': c1,
 
515
             b'HEAD': self.remote_real.head(),
 
516
             })
430
517
 
431
518
    def test_annotated_tag(self):
432
519
        c1 = self.remote_real.do_commit(
433
 
                message=b'message',
434
 
                committer=b'committer <committer@example.com>',
435
 
                author=b'author <author@example.com>')
 
520
            message=b'message',
 
521
            committer=b'committer <committer@example.com>',
 
522
            author=b'author <author@example.com>')
436
523
        c2 = self.remote_real.do_commit(
437
 
                message=b'another commit',
438
 
                committer=b'committer <committer@example.com>',
439
 
                author=b'author <author@example.com>')
 
524
            message=b'another commit',
 
525
            committer=b'committer <committer@example.com>',
 
526
            author=b'author <author@example.com>')
440
527
 
441
528
        porcelain.tag_create(
442
 
                self.remote_real,
443
 
                tag=b"blah",
444
 
                author=b'author <author@example.com>',
445
 
                objectish=c2,
446
 
                tag_time=int(time.time()),
447
 
                tag_timezone=0,
448
 
                annotated=True,
449
 
                message=b"Annotated tag")
 
529
            self.remote_real,
 
530
            tag=b"blah",
 
531
            author=b'author <author@example.com>',
 
532
            objectish=c2,
 
533
            tag_time=int(time.time()),
 
534
            tag_timezone=0,
 
535
            annotated=True,
 
536
            message=b"Annotated tag")
450
537
 
451
538
        remote = ControlDir.open(self.remote_url)
452
539
        remote_branch = remote.open_branch()
454
541
            'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
455
542
            remote_branch.tags.get_tag_dict())
456
543
 
457
 
    def tetst_get_branch_reference(self):
 
544
    def test_get_branch_reference(self):
458
545
        c1 = self.remote_real.do_commit(
459
 
                message=b'message',
460
 
                committer=b'committer <committer@example.com>',
461
 
                author=b'author <author@example.com>')
 
546
            message=b'message',
 
547
            committer=b'committer <committer@example.com>',
 
548
            author=b'author <author@example.com>')
462
549
        c2 = self.remote_real.do_commit(
463
 
                message=b'another commit',
464
 
                committer=b'committer <committer@example.com>',
465
 
                author=b'author <author@example.com>')
 
550
            message=b'another commit',
 
551
            committer=b'committer <committer@example.com>',
 
552
            author=b'author <author@example.com>')
466
553
 
467
554
        remote = ControlDir.open(self.remote_url)
468
555
        self.assertEqual(b'refs/heads/master', remote.get_branch_reference(''))
469
556
        self.assertEqual(None, remote.get_branch_reference('master'))
 
557
 
 
558
    def test_get_branch_nick(self):
 
559
        c1 = self.remote_real.do_commit(
 
560
            message=b'message',
 
561
            committer=b'committer <committer@example.com>',
 
562
            author=b'author <author@example.com>')
 
563
        remote = ControlDir.open(self.remote_url)
 
564
        self.assertEqual('master', remote.open_branch().nick)