/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: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
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
    _test_needs_features = [ExecutableFeature('git')]
 
148
 
 
149
    def setUp(self):
 
150
        TestCaseWithTransport.setUp(self)
 
151
        self.remote_real = GitRepo.init('remote', mkdir=True)
 
152
        self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
 
153
        self.permit_url(self.remote_url)
 
154
 
 
155
    def test_set_last_revision_info(self):
 
156
        c1 = self.remote_real.do_commit(
 
157
            message=b'message 1',
 
158
            committer=b'committer <committer@example.com>',
 
159
            author=b'author <author@example.com>',
 
160
            ref=b'refs/heads/newbranch')
 
161
        c2 = self.remote_real.do_commit(
 
162
            message=b'message 2',
 
163
            committer=b'committer <committer@example.com>',
 
164
            author=b'author <author@example.com>',
 
165
            ref=b'refs/heads/newbranch')
 
166
 
 
167
        remote = ControlDir.open(self.remote_url)
 
168
        newbranch = remote.open_branch('newbranch')
 
169
        self.assertEqual(newbranch.lookup_foreign_revision_id(c2),
 
170
                         newbranch.last_revision())
 
171
        newbranch.set_last_revision_info(
 
172
            1, newbranch.lookup_foreign_revision_id(c1))
 
173
        self.assertEqual(c1, self.remote_real.refs[b'refs/heads/newbranch'])
 
174
        self.assertEqual(newbranch.last_revision(),
 
175
                         newbranch.lookup_foreign_revision_id(c1))
 
176
 
 
177
 
126
178
class FetchFromRemoteTestBase(object):
127
179
 
128
180
    _test_needs_features = [ExecutableFeature('git')]
137
189
 
138
190
    def test_sprout_simple(self):
139
191
        self.remote_real.do_commit(
140
 
                message=b'message',
141
 
                committer=b'committer <committer@example.com>',
142
 
                author=b'author <author@example.com>')
 
192
            message=b'message',
 
193
            committer=b'committer <committer@example.com>',
 
194
            author=b'author <author@example.com>')
143
195
 
144
196
        remote = ControlDir.open(self.remote_url)
145
197
        self.make_controldir('local', format=self._to_format)
146
198
        local = remote.sprout('local')
147
199
        self.assertEqual(
148
 
                default_mapping.revision_id_foreign_to_bzr(self.remote_real.head()),
149
 
                local.open_branch().last_revision())
 
200
            default_mapping.revision_id_foreign_to_bzr(
 
201
                self.remote_real.head()),
 
202
            local.open_branch().last_revision())
150
203
 
151
204
    def test_sprout_with_tags(self):
152
205
        c1 = self.remote_real.do_commit(
153
 
                message=b'message',
154
 
                committer=b'committer <committer@example.com>',
155
 
                author=b'author <author@example.com>')
 
206
            message=b'message',
 
207
            committer=b'committer <committer@example.com>',
 
208
            author=b'author <author@example.com>')
156
209
        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')
 
210
            message=b'another commit',
 
211
            committer=b'committer <committer@example.com>',
 
212
            author=b'author <author@example.com>',
 
213
            ref=b'refs/tags/another')
161
214
        self.remote_real.refs[b'refs/tags/blah'] = self.remote_real.head()
162
215
 
163
216
        remote = ControlDir.open(self.remote_url)
165
218
        local = remote.sprout('local')
166
219
        local_branch = local.open_branch()
167
220
        self.assertEqual(
168
 
                default_mapping.revision_id_foreign_to_bzr(c1),
169
 
                local_branch.last_revision())
 
221
            default_mapping.revision_id_foreign_to_bzr(c1),
 
222
            local_branch.last_revision())
170
223
        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())
 
224
            {'blah': local_branch.last_revision(),
 
225
             'another': default_mapping.revision_id_foreign_to_bzr(c2)},
 
226
            local_branch.tags.get_tag_dict())
174
227
 
175
228
    def test_sprout_with_annotated_tag(self):
176
229
        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):
 
230
            message=b'message',
 
231
            committer=b'committer <committer@example.com>',
 
232
            author=b'author <author@example.com>')
 
233
        c2 = self.remote_real.do_commit(
 
234
            message=b'another commit',
 
235
            committer=b'committer <committer@example.com>',
 
236
            author=b'author <author@example.com>',
 
237
            ref=b'refs/heads/another')
 
238
        porcelain.tag_create(
 
239
            self.remote_real,
 
240
            tag=b"blah",
 
241
            author=b'author <author@example.com>',
 
242
            objectish=c2,
 
243
            tag_time=int(time.time()),
 
244
            tag_timezone=0,
 
245
            annotated=True,
 
246
            message=b"Annotated tag")
 
247
 
 
248
        remote = ControlDir.open(self.remote_url)
 
249
        self.make_controldir('local', format=self._to_format)
 
250
        local = remote.sprout(
 
251
            'local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
 
252
        local_branch = local.open_branch()
 
253
        self.assertEqual(
 
254
            default_mapping.revision_id_foreign_to_bzr(c1),
 
255
            local_branch.last_revision())
 
256
        self.assertEqual(
 
257
            {'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
 
258
            local_branch.tags.get_tag_dict())
 
259
 
 
260
    def test_sprout_with_annotated_tag_unreferenced(self):
 
261
        c1 = self.remote_real.do_commit(
 
262
            message=b'message',
 
263
            committer=b'committer <committer@example.com>',
 
264
            author=b'author <author@example.com>')
 
265
        c2 = self.remote_real.do_commit(
 
266
            message=b'another commit',
 
267
            committer=b'committer <committer@example.com>',
 
268
            author=b'author <author@example.com>')
 
269
        porcelain.tag_create(
 
270
            self.remote_real,
 
271
            tag=b"blah",
 
272
            author=b'author <author@example.com>',
 
273
            objectish=c1,
 
274
            tag_time=int(time.time()),
 
275
            tag_timezone=0,
 
276
            annotated=True,
 
277
            message=b"Annotated tag")
 
278
 
 
279
        remote = ControlDir.open(self.remote_url)
 
280
        self.make_controldir('local', format=self._to_format)
 
281
        local = remote.sprout(
 
282
            'local',
 
283
            revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
 
284
        local_branch = local.open_branch()
 
285
        self.assertEqual(
 
286
            default_mapping.revision_id_foreign_to_bzr(c1),
 
287
            local_branch.last_revision())
 
288
        self.assertEqual(
 
289
            {'blah': default_mapping.revision_id_foreign_to_bzr(c1)},
 
290
            local_branch.tags.get_tag_dict())
 
291
 
 
292
 
 
293
class FetchFromRemoteToBzrTests(FetchFromRemoteTestBase, TestCaseWithTransport):
208
294
 
209
295
    _to_format = '2a'
210
296
 
211
297
 
212
 
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase,TestCaseWithTransport):
 
298
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase, TestCaseWithTransport):
213
299
 
214
300
    _to_format = 'git'
215
301
 
236
322
        if self._from_format == 'git':
237
323
            result = remote.push_branch(wt.branch, name='newbranch')
238
324
        else:
239
 
            result = remote.push_branch(wt.branch, lossy=True, name='newbranch')
 
325
            result = remote.push_branch(
 
326
                wt.branch, lossy=True, name='newbranch')
240
327
 
241
328
        self.assertEqual(0, result.old_revno)
242
329
        if self._from_format == 'git':
247
334
        result.report(BytesIO())
248
335
 
249
336
        self.assertEqual(
250
 
                {b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
251
 
                },
252
 
                self.remote_real.get_refs())
 
337
            {b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
 
338
             },
 
339
            self.remote_real.get_refs())
 
340
 
 
341
    def test_push_branch_new_with_tags(self):
 
342
        remote = ControlDir.open(self.remote_url)
 
343
        builder = self.make_branch_builder('local', format=self._from_format)
 
344
        builder.start_series()
 
345
        rev_1 = builder.build_snapshot(None, [
 
346
            ('add', ('', None, 'directory', '')),
 
347
            ('add', ('filename', None, 'file', b'content'))])
 
348
        rev_2 = builder.build_snapshot(
 
349
            [rev_1], [('modify', ('filename', b'new-content\n'))])
 
350
        rev_3 = builder.build_snapshot(
 
351
            [rev_1], [('modify', ('filename', b'new-new-content\n'))])
 
352
        builder.finish_series()
 
353
        branch = builder.get_branch()
 
354
        try:
 
355
            branch.tags.set_tag('atag', rev_2)
 
356
        except TagsNotSupported:
 
357
            raise TestNotApplicable('source format does not support tags')
 
358
 
 
359
        branch.get_config_stack().set('branch.fetch_tags', True)
 
360
        if self._from_format == 'git':
 
361
            result = remote.push_branch(branch, name='newbranch')
 
362
        else:
 
363
            result = remote.push_branch(
 
364
                branch, lossy=True, name='newbranch')
 
365
 
 
366
        self.assertEqual(0, result.old_revno)
 
367
        if self._from_format == 'git':
 
368
            self.assertEqual(2, result.new_revno)
 
369
        else:
 
370
            self.assertIs(None, result.new_revno)
 
371
 
 
372
        result.report(BytesIO())
 
373
 
 
374
        self.assertEqual(
 
375
            {b'refs/heads/newbranch', b'refs/tags/atag'},
 
376
            set(self.remote_real.get_refs().keys()))
253
377
 
254
378
    def test_push(self):
255
379
        c1 = self.remote_real.do_commit(
256
 
                message=b'message',
257
 
                committer=b'committer <committer@example.com>',
258
 
                author=b'author <author@example.com>')
 
380
            message=b'message',
 
381
            committer=b'committer <committer@example.com>',
 
382
            author=b'author <author@example.com>')
259
383
 
260
384
        remote = ControlDir.open(self.remote_url)
261
385
        self.make_controldir('local', format=self._from_format)
270
394
        if self._from_format == 'git':
271
395
            result = wt.branch.push(remote.create_branch('newbranch'))
272
396
        else:
273
 
            result = wt.branch.push(remote.create_branch('newbranch'), lossy=True)
 
397
            result = wt.branch.push(
 
398
                remote.create_branch('newbranch'), lossy=True)
274
399
 
275
400
        self.assertEqual(0, result.old_revno)
276
401
        self.assertEqual(2, result.new_revno)
278
403
        result.report(BytesIO())
279
404
 
280
405
        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())
 
406
            {b'refs/heads/master': self.remote_real.head(),
 
407
             b'HEAD': self.remote_real.head(),
 
408
             b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
 
409
             b'refs/tags/sometag': self.remote_real.refs[b'refs/heads/newbranch'],
 
410
             },
 
411
            self.remote_real.get_refs())
287
412
 
288
413
    def test_push_diverged(self):
289
414
        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')
 
415
            message=b'message',
 
416
            committer=b'committer <committer@example.com>',
 
417
            author=b'author <author@example.com>',
 
418
            ref=b'refs/heads/newbranch')
294
419
 
295
420
        remote = ControlDir.open(self.remote_url)
296
421
        wt = self.make_branch_and_tree('local', format=self._from_format)
302
427
        if self._from_format == 'git':
303
428
            self.assertRaises(DivergedBranches, wt.branch.push, newbranch)
304
429
        else:
305
 
            self.assertRaises(DivergedBranches, wt.branch.push, newbranch, lossy=True)
 
430
            self.assertRaises(DivergedBranches, wt.branch.push,
 
431
                              newbranch, lossy=True)
306
432
 
307
433
        self.assertEqual(
308
 
                {b'refs/heads/newbranch': c1 },
309
 
                self.remote_real.get_refs())
 
434
            {b'refs/heads/newbranch': c1},
 
435
            self.remote_real.get_refs())
310
436
 
311
437
        if self._from_format == 'git':
312
438
            wt.branch.push(newbranch, overwrite=True)
316
442
        self.assertNotEqual(c1, self.remote_real.refs[b'refs/heads/newbranch'])
317
443
 
318
444
 
319
 
class PushToRemoteFromBzrTests(PushToRemoteBase,TestCaseWithTransport):
 
445
class PushToRemoteFromBzrTests(PushToRemoteBase, TestCaseWithTransport):
320
446
 
321
447
    _from_format = '2a'
322
448
 
323
449
 
324
 
class PushToRemoteFromGitTests(PushToRemoteBase,TestCaseWithTransport):
 
450
class PushToRemoteFromGitTests(PushToRemoteBase, TestCaseWithTransport):
325
451
 
326
452
    _from_format = 'git'
327
453
 
338
464
 
339
465
    def test_remove_branch(self):
340
466
        c1 = self.remote_real.do_commit(
341
 
                message=b'message',
342
 
                committer=b'committer <committer@example.com>',
343
 
                author=b'author <author@example.com>')
 
467
            message=b'message',
 
468
            committer=b'committer <committer@example.com>',
 
469
            author=b'author <author@example.com>')
344
470
        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')
 
471
            message=b'another commit',
 
472
            committer=b'committer <committer@example.com>',
 
473
            author=b'author <author@example.com>',
 
474
            ref=b'refs/heads/blah')
349
475
 
350
476
        remote = ControlDir.open(self.remote_url)
351
477
        remote.destroy_branch(name='blah')
352
478
        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
 
                })
 
479
            self.remote_real.get_refs(),
 
480
            {b'refs/heads/master': self.remote_real.head(),
 
481
             b'HEAD': self.remote_real.head(),
 
482
             })
357
483
 
358
484
    def test_list_branches(self):
359
485
        c1 = self.remote_real.do_commit(
360
 
                message=b'message',
361
 
                committer=b'committer <committer@example.com>',
362
 
                author=b'author <author@example.com>')
 
486
            message=b'message',
 
487
            committer=b'committer <committer@example.com>',
 
488
            author=b'author <author@example.com>')
363
489
        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')
 
490
            message=b'another commit',
 
491
            committer=b'committer <committer@example.com>',
 
492
            author=b'author <author@example.com>',
 
493
            ref=b'refs/heads/blah')
368
494
 
369
495
        remote = ControlDir.open(self.remote_url)
370
496
        self.assertEqual(
371
 
                set(['master', 'blah', 'master']),
372
 
                set([b.name for b in remote.list_branches()]))
 
497
            set(['master', 'blah', 'master']),
 
498
            set([b.name for b in remote.list_branches()]))
373
499
 
374
500
    def test_get_branches(self):
375
501
        c1 = self.remote_real.do_commit(
376
 
                message=b'message',
377
 
                committer=b'committer <committer@example.com>',
378
 
                author=b'author <author@example.com>')
 
502
            message=b'message',
 
503
            committer=b'committer <committer@example.com>',
 
504
            author=b'author <author@example.com>')
379
505
        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')
 
506
            message=b'another commit',
 
507
            committer=b'committer <committer@example.com>',
 
508
            author=b'author <author@example.com>',
 
509
            ref=b'refs/heads/blah')
384
510
 
385
511
        remote = ControlDir.open(self.remote_url)
386
512
        self.assertEqual(
387
 
                {'': 'master', 'blah': 'blah', 'master': 'master'},
388
 
                {n: b.name for (n, b) in remote.get_branches().items()})
 
513
            {'': 'master', 'blah': 'blah', 'master': 'master'},
 
514
            {n: b.name for (n, b) in remote.get_branches().items()})
389
515
 
390
516
    def test_remove_tag(self):
391
517
        c1 = self.remote_real.do_commit(
392
 
                message=b'message',
393
 
                committer=b'committer <committer@example.com>',
394
 
                author=b'author <author@example.com>')
 
518
            message=b'message',
 
519
            committer=b'committer <committer@example.com>',
 
520
            author=b'author <author@example.com>')
395
521
        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')
 
522
            message=b'another commit',
 
523
            committer=b'committer <committer@example.com>',
 
524
            author=b'author <author@example.com>',
 
525
            ref=b'refs/tags/blah')
400
526
 
401
527
        remote = ControlDir.open(self.remote_url)
402
528
        remote_branch = remote.open_branch()
403
529
        remote_branch.tags.delete_tag('blah')
404
530
        self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah')
405
531
        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
 
                })
 
532
            self.remote_real.get_refs(),
 
533
            {b'refs/heads/master': self.remote_real.head(),
 
534
             b'HEAD': self.remote_real.head(),
 
535
             })
410
536
 
411
537
    def test_set_tag(self):
412
538
        c1 = self.remote_real.do_commit(
413
 
                message=b'message',
414
 
                committer=b'committer <committer@example.com>',
415
 
                author=b'author <author@example.com>')
 
539
            message=b'message',
 
540
            committer=b'committer <committer@example.com>',
 
541
            author=b'author <author@example.com>')
416
542
        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>')
 
543
            message=b'another commit',
 
544
            committer=b'committer <committer@example.com>',
 
545
            author=b'author <author@example.com>')
420
546
 
421
547
        remote = ControlDir.open(self.remote_url)
422
548
        remote.open_branch().tags.set_tag(
423
549
            b'blah', default_mapping.revision_id_foreign_to_bzr(c1))
424
550
        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
 
                })
 
551
            self.remote_real.get_refs(),
 
552
            {b'refs/heads/master': self.remote_real.head(),
 
553
             b'refs/tags/blah': c1,
 
554
             b'HEAD': self.remote_real.head(),
 
555
             })
430
556
 
431
557
    def test_annotated_tag(self):
432
558
        c1 = self.remote_real.do_commit(
433
 
                message=b'message',
434
 
                committer=b'committer <committer@example.com>',
435
 
                author=b'author <author@example.com>')
 
559
            message=b'message',
 
560
            committer=b'committer <committer@example.com>',
 
561
            author=b'author <author@example.com>')
436
562
        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>')
 
563
            message=b'another commit',
 
564
            committer=b'committer <committer@example.com>',
 
565
            author=b'author <author@example.com>')
440
566
 
441
567
        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")
 
568
            self.remote_real,
 
569
            tag=b"blah",
 
570
            author=b'author <author@example.com>',
 
571
            objectish=c2,
 
572
            tag_time=int(time.time()),
 
573
            tag_timezone=0,
 
574
            annotated=True,
 
575
            message=b"Annotated tag")
450
576
 
451
577
        remote = ControlDir.open(self.remote_url)
452
578
        remote_branch = remote.open_branch()
454
580
            'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
455
581
            remote_branch.tags.get_tag_dict())
456
582
 
457
 
    def tetst_get_branch_reference(self):
 
583
    def test_get_branch_reference(self):
458
584
        c1 = self.remote_real.do_commit(
459
 
                message=b'message',
460
 
                committer=b'committer <committer@example.com>',
461
 
                author=b'author <author@example.com>')
 
585
            message=b'message',
 
586
            committer=b'committer <committer@example.com>',
 
587
            author=b'author <author@example.com>')
462
588
        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>')
 
589
            message=b'another commit',
 
590
            committer=b'committer <committer@example.com>',
 
591
            author=b'author <author@example.com>')
466
592
 
467
593
        remote = ControlDir.open(self.remote_url)
468
594
        self.assertEqual(b'refs/heads/master', remote.get_branch_reference(''))
469
595
        self.assertEqual(None, remote.get_branch_reference('master'))
 
596
 
 
597
    def test_get_branch_nick(self):
 
598
        c1 = self.remote_real.do_commit(
 
599
            message=b'message',
 
600
            committer=b'committer <committer@example.com>',
 
601
            author=b'author <author@example.com>')
 
602
        remote = ControlDir.open(self.remote_url)
 
603
        self.assertEqual('master', remote.open_branch().nick)