/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-02-03 01:42:11 UTC
  • mto: This revision was merged to the branch mainline in revision 7267.
  • Revision ID: jelmer@jelmer.uk-20190203014211-poj1fv922sejfsb4
Don't require that short git shas have an even number of characters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2010-2018 Jelmer Vernooij <jelmer@jelmer.uk>
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
"""Test the smart client."""
 
18
 
 
19
from __future__ import absolute_import
 
20
 
 
21
from io import BytesIO
 
22
 
 
23
import os
 
24
import time
 
25
 
 
26
from ...controldir import ControlDir
 
27
from ...errors import (
 
28
    DivergedBranches,
 
29
    NotBranchError,
 
30
    NoSuchTag,
 
31
    PermissionDenied,
 
32
    )
 
33
 
 
34
from ...tests import (
 
35
    TestCase,
 
36
    TestCaseWithTransport,
 
37
    )
 
38
from ...tests.features import ExecutableFeature
 
39
 
 
40
from ..mapping import default_mapping
 
41
from ..remote import (
 
42
    split_git_url,
 
43
    parse_git_error,
 
44
    HeadUpdateFailed,
 
45
    RemoteGitError,
 
46
    RemoteGitBranchFormat,
 
47
    )
 
48
 
 
49
from dulwich import porcelain
 
50
from dulwich.repo import Repo as GitRepo
 
51
 
 
52
 
 
53
class SplitUrlTests(TestCase):
 
54
 
 
55
    def test_simple(self):
 
56
        self.assertEqual(("foo", None, None, "/bar"),
 
57
                         split_git_url("git://foo/bar"))
 
58
 
 
59
    def test_port(self):
 
60
        self.assertEqual(("foo", 343, None, "/bar"),
 
61
                         split_git_url("git://foo:343/bar"))
 
62
 
 
63
    def test_username(self):
 
64
        self.assertEqual(("foo", None, "la", "/bar"),
 
65
                         split_git_url("git://la@foo/bar"))
 
66
 
 
67
    def test_nopath(self):
 
68
        self.assertEqual(("foo", None, None, "/"),
 
69
                         split_git_url("git://foo/"))
 
70
 
 
71
    def test_slashpath(self):
 
72
        self.assertEqual(("foo", None, None, "//bar"),
 
73
                         split_git_url("git://foo//bar"))
 
74
 
 
75
    def test_homedir(self):
 
76
        self.assertEqual(("foo", None, None, "~bar"),
 
77
                         split_git_url("git://foo/~bar"))
 
78
 
 
79
 
 
80
class ParseGitErrorTests(TestCase):
 
81
 
 
82
    def test_unknown(self):
 
83
        e = parse_git_error("url", "foo")
 
84
        self.assertIsInstance(e, RemoteGitError)
 
85
 
 
86
    def test_notbrancherror(self):
 
87
        e = parse_git_error("url", "\n Could not find Repository foo/bar")
 
88
        self.assertIsInstance(e, NotBranchError)
 
89
 
 
90
    def test_notbrancherror_launchpad(self):
 
91
        e = parse_git_error("url", "Repository 'foo/bar' not found.")
 
92
        self.assertIsInstance(e, NotBranchError)
 
93
 
 
94
    def test_notbrancherror_github(self):
 
95
        e = parse_git_error("url", "Repository not found.\n")
 
96
        self.assertIsInstance(e, NotBranchError)
 
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
 
 
103
    def test_head_update(self):
 
104
        e = parse_git_error("url", "HEAD failed to update\n")
 
105
        self.assertIsInstance(e, HeadUpdateFailed)
 
106
 
 
107
    def test_permission_dnied(self):
 
108
        e = parse_git_error(
 
109
            "url",
 
110
            "access denied or repository not exported: /debian/altermime.git")
 
111
        self.assertIsInstance(e, PermissionDenied)
 
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
 
 
127
 
 
128
class TestRemoteGitBranchFormat(TestCase):
 
129
 
 
130
    def setUp(self):
 
131
        super(TestRemoteGitBranchFormat, self).setUp()
 
132
        self.format = RemoteGitBranchFormat()
 
133
 
 
134
    def test_get_format_description(self):
 
135
        self.assertEqual("Remote Git Branch",
 
136
                         self.format.get_format_description())
 
137
 
 
138
    def test_get_network_name(self):
 
139
        self.assertEqual(b"git", self.format.network_name())
 
140
 
 
141
    def test_supports_tags(self):
 
142
        self.assertTrue(self.format.supports_tags())
 
143
 
 
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
 
 
178
class FetchFromRemoteTestBase(object):
 
179
 
 
180
    _test_needs_features = [ExecutableFeature('git')]
 
181
 
 
182
    _to_format = None
 
183
 
 
184
    def setUp(self):
 
185
        TestCaseWithTransport.setUp(self)
 
186
        self.remote_real = GitRepo.init('remote', mkdir=True)
 
187
        self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
 
188
        self.permit_url(self.remote_url)
 
189
 
 
190
    def test_sprout_simple(self):
 
191
        self.remote_real.do_commit(
 
192
            message=b'message',
 
193
            committer=b'committer <committer@example.com>',
 
194
            author=b'author <author@example.com>')
 
195
 
 
196
        remote = ControlDir.open(self.remote_url)
 
197
        self.make_controldir('local', format=self._to_format)
 
198
        local = remote.sprout('local')
 
199
        self.assertEqual(
 
200
            default_mapping.revision_id_foreign_to_bzr(
 
201
                self.remote_real.head()),
 
202
            local.open_branch().last_revision())
 
203
 
 
204
    def test_sprout_with_tags(self):
 
205
        c1 = self.remote_real.do_commit(
 
206
            message=b'message',
 
207
            committer=b'committer <committer@example.com>',
 
208
            author=b'author <author@example.com>')
 
209
        c2 = self.remote_real.do_commit(
 
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')
 
214
        self.remote_real.refs[b'refs/tags/blah'] = self.remote_real.head()
 
215
 
 
216
        remote = ControlDir.open(self.remote_url)
 
217
        self.make_controldir('local', format=self._to_format)
 
218
        local = remote.sprout('local')
 
219
        local_branch = local.open_branch()
 
220
        self.assertEqual(
 
221
            default_mapping.revision_id_foreign_to_bzr(c1),
 
222
            local_branch.last_revision())
 
223
        self.assertEqual(
 
224
            {'blah': local_branch.last_revision(),
 
225
             'another': default_mapping.revision_id_foreign_to_bzr(c2)},
 
226
            local_branch.tags.get_tag_dict())
 
227
 
 
228
    def test_sprout_with_annotated_tag(self):
 
229
        c1 = self.remote_real.do_commit(
 
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):
 
294
 
 
295
    _to_format = '2a'
 
296
 
 
297
 
 
298
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase, TestCaseWithTransport):
 
299
 
 
300
    _to_format = 'git'
 
301
 
 
302
 
 
303
class PushToRemoteBase(object):
 
304
 
 
305
    _test_needs_features = [ExecutableFeature('git')]
 
306
 
 
307
    _from_format = None
 
308
 
 
309
    def setUp(self):
 
310
        TestCaseWithTransport.setUp(self)
 
311
        self.remote_real = GitRepo.init('remote', mkdir=True)
 
312
        self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
 
313
        self.permit_url(self.remote_url)
 
314
 
 
315
    def test_push_branch_new(self):
 
316
        remote = ControlDir.open(self.remote_url)
 
317
        wt = self.make_branch_and_tree('local', format=self._from_format)
 
318
        self.build_tree(['local/blah'])
 
319
        wt.add(['blah'])
 
320
        revid = wt.commit('blah')
 
321
 
 
322
        if self._from_format == 'git':
 
323
            result = remote.push_branch(wt.branch, name='newbranch')
 
324
        else:
 
325
            result = remote.push_branch(
 
326
                wt.branch, lossy=True, name='newbranch')
 
327
 
 
328
        self.assertEqual(0, result.old_revno)
 
329
        if self._from_format == 'git':
 
330
            self.assertEqual(1, result.new_revno)
 
331
        else:
 
332
            self.assertIs(None, result.new_revno)
 
333
 
 
334
        result.report(BytesIO())
 
335
 
 
336
        self.assertEqual(
 
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(self):
 
342
        c1 = self.remote_real.do_commit(
 
343
            message=b'message',
 
344
            committer=b'committer <committer@example.com>',
 
345
            author=b'author <author@example.com>')
 
346
 
 
347
        remote = ControlDir.open(self.remote_url)
 
348
        self.make_controldir('local', format=self._from_format)
 
349
        local = remote.sprout('local')
 
350
        self.build_tree(['local/blah'])
 
351
        wt = local.open_workingtree()
 
352
        wt.add(['blah'])
 
353
        revid = wt.commit('blah')
 
354
        wt.branch.tags.set_tag('sometag', revid)
 
355
        wt.branch.get_config_stack().set('branch.fetch_tags', True)
 
356
 
 
357
        if self._from_format == 'git':
 
358
            result = wt.branch.push(remote.create_branch('newbranch'))
 
359
        else:
 
360
            result = wt.branch.push(
 
361
                remote.create_branch('newbranch'), lossy=True)
 
362
 
 
363
        self.assertEqual(0, result.old_revno)
 
364
        self.assertEqual(2, result.new_revno)
 
365
 
 
366
        result.report(BytesIO())
 
367
 
 
368
        self.assertEqual(
 
369
            {b'refs/heads/master': self.remote_real.head(),
 
370
             b'HEAD': self.remote_real.head(),
 
371
             b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
 
372
             b'refs/tags/sometag': self.remote_real.refs[b'refs/heads/newbranch'],
 
373
             },
 
374
            self.remote_real.get_refs())
 
375
 
 
376
    def test_push_diverged(self):
 
377
        c1 = self.remote_real.do_commit(
 
378
            message=b'message',
 
379
            committer=b'committer <committer@example.com>',
 
380
            author=b'author <author@example.com>',
 
381
            ref=b'refs/heads/newbranch')
 
382
 
 
383
        remote = ControlDir.open(self.remote_url)
 
384
        wt = self.make_branch_and_tree('local', format=self._from_format)
 
385
        self.build_tree(['local/blah'])
 
386
        wt.add(['blah'])
 
387
        revid = wt.commit('blah')
 
388
 
 
389
        newbranch = remote.open_branch('newbranch')
 
390
        if self._from_format == 'git':
 
391
            self.assertRaises(DivergedBranches, wt.branch.push, newbranch)
 
392
        else:
 
393
            self.assertRaises(DivergedBranches, wt.branch.push,
 
394
                              newbranch, lossy=True)
 
395
 
 
396
        self.assertEqual(
 
397
            {b'refs/heads/newbranch': c1},
 
398
            self.remote_real.get_refs())
 
399
 
 
400
        if self._from_format == 'git':
 
401
            wt.branch.push(newbranch, overwrite=True)
 
402
        else:
 
403
            wt.branch.push(newbranch, lossy=True, overwrite=True)
 
404
 
 
405
        self.assertNotEqual(c1, self.remote_real.refs[b'refs/heads/newbranch'])
 
406
 
 
407
 
 
408
class PushToRemoteFromBzrTests(PushToRemoteBase, TestCaseWithTransport):
 
409
 
 
410
    _from_format = '2a'
 
411
 
 
412
 
 
413
class PushToRemoteFromGitTests(PushToRemoteBase, TestCaseWithTransport):
 
414
 
 
415
    _from_format = 'git'
 
416
 
 
417
 
 
418
class RemoteControlDirTests(TestCaseWithTransport):
 
419
 
 
420
    _test_needs_features = [ExecutableFeature('git')]
 
421
 
 
422
    def setUp(self):
 
423
        TestCaseWithTransport.setUp(self)
 
424
        self.remote_real = GitRepo.init('remote', mkdir=True)
 
425
        self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
 
426
        self.permit_url(self.remote_url)
 
427
 
 
428
    def test_remove_branch(self):
 
429
        c1 = self.remote_real.do_commit(
 
430
            message=b'message',
 
431
            committer=b'committer <committer@example.com>',
 
432
            author=b'author <author@example.com>')
 
433
        c2 = self.remote_real.do_commit(
 
434
            message=b'another commit',
 
435
            committer=b'committer <committer@example.com>',
 
436
            author=b'author <author@example.com>',
 
437
            ref=b'refs/heads/blah')
 
438
 
 
439
        remote = ControlDir.open(self.remote_url)
 
440
        remote.destroy_branch(name='blah')
 
441
        self.assertEqual(
 
442
            self.remote_real.get_refs(),
 
443
            {b'refs/heads/master': self.remote_real.head(),
 
444
             b'HEAD': self.remote_real.head(),
 
445
             })
 
446
 
 
447
    def test_list_branches(self):
 
448
        c1 = self.remote_real.do_commit(
 
449
            message=b'message',
 
450
            committer=b'committer <committer@example.com>',
 
451
            author=b'author <author@example.com>')
 
452
        c2 = self.remote_real.do_commit(
 
453
            message=b'another commit',
 
454
            committer=b'committer <committer@example.com>',
 
455
            author=b'author <author@example.com>',
 
456
            ref=b'refs/heads/blah')
 
457
 
 
458
        remote = ControlDir.open(self.remote_url)
 
459
        self.assertEqual(
 
460
            set(['master', 'blah', 'master']),
 
461
            set([b.name for b in remote.list_branches()]))
 
462
 
 
463
    def test_get_branches(self):
 
464
        c1 = self.remote_real.do_commit(
 
465
            message=b'message',
 
466
            committer=b'committer <committer@example.com>',
 
467
            author=b'author <author@example.com>')
 
468
        c2 = self.remote_real.do_commit(
 
469
            message=b'another commit',
 
470
            committer=b'committer <committer@example.com>',
 
471
            author=b'author <author@example.com>',
 
472
            ref=b'refs/heads/blah')
 
473
 
 
474
        remote = ControlDir.open(self.remote_url)
 
475
        self.assertEqual(
 
476
            {'': 'master', 'blah': 'blah', 'master': 'master'},
 
477
            {n: b.name for (n, b) in remote.get_branches().items()})
 
478
 
 
479
    def test_remove_tag(self):
 
480
        c1 = self.remote_real.do_commit(
 
481
            message=b'message',
 
482
            committer=b'committer <committer@example.com>',
 
483
            author=b'author <author@example.com>')
 
484
        c2 = self.remote_real.do_commit(
 
485
            message=b'another commit',
 
486
            committer=b'committer <committer@example.com>',
 
487
            author=b'author <author@example.com>',
 
488
            ref=b'refs/tags/blah')
 
489
 
 
490
        remote = ControlDir.open(self.remote_url)
 
491
        remote_branch = remote.open_branch()
 
492
        remote_branch.tags.delete_tag('blah')
 
493
        self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah')
 
494
        self.assertEqual(
 
495
            self.remote_real.get_refs(),
 
496
            {b'refs/heads/master': self.remote_real.head(),
 
497
             b'HEAD': self.remote_real.head(),
 
498
             })
 
499
 
 
500
    def test_set_tag(self):
 
501
        c1 = self.remote_real.do_commit(
 
502
            message=b'message',
 
503
            committer=b'committer <committer@example.com>',
 
504
            author=b'author <author@example.com>')
 
505
        c2 = self.remote_real.do_commit(
 
506
            message=b'another commit',
 
507
            committer=b'committer <committer@example.com>',
 
508
            author=b'author <author@example.com>')
 
509
 
 
510
        remote = ControlDir.open(self.remote_url)
 
511
        remote.open_branch().tags.set_tag(
 
512
            b'blah', default_mapping.revision_id_foreign_to_bzr(c1))
 
513
        self.assertEqual(
 
514
            self.remote_real.get_refs(),
 
515
            {b'refs/heads/master': self.remote_real.head(),
 
516
             b'refs/tags/blah': c1,
 
517
             b'HEAD': self.remote_real.head(),
 
518
             })
 
519
 
 
520
    def test_annotated_tag(self):
 
521
        c1 = self.remote_real.do_commit(
 
522
            message=b'message',
 
523
            committer=b'committer <committer@example.com>',
 
524
            author=b'author <author@example.com>')
 
525
        c2 = self.remote_real.do_commit(
 
526
            message=b'another commit',
 
527
            committer=b'committer <committer@example.com>',
 
528
            author=b'author <author@example.com>')
 
529
 
 
530
        porcelain.tag_create(
 
531
            self.remote_real,
 
532
            tag=b"blah",
 
533
            author=b'author <author@example.com>',
 
534
            objectish=c2,
 
535
            tag_time=int(time.time()),
 
536
            tag_timezone=0,
 
537
            annotated=True,
 
538
            message=b"Annotated tag")
 
539
 
 
540
        remote = ControlDir.open(self.remote_url)
 
541
        remote_branch = remote.open_branch()
 
542
        self.assertEqual({
 
543
            'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
 
544
            remote_branch.tags.get_tag_dict())
 
545
 
 
546
    def test_get_branch_reference(self):
 
547
        c1 = self.remote_real.do_commit(
 
548
            message=b'message',
 
549
            committer=b'committer <committer@example.com>',
 
550
            author=b'author <author@example.com>')
 
551
        c2 = self.remote_real.do_commit(
 
552
            message=b'another commit',
 
553
            committer=b'committer <committer@example.com>',
 
554
            author=b'author <author@example.com>')
 
555
 
 
556
        remote = ControlDir.open(self.remote_url)
 
557
        self.assertEqual(b'refs/heads/master', remote.get_branch_reference(''))
 
558
        self.assertEqual(None, remote.get_branch_reference('master'))
 
559
 
 
560
    def test_get_branch_nick(self):
 
561
        c1 = self.remote_real.do_commit(
 
562
            message=b'message',
 
563
            committer=b'committer <committer@example.com>',
 
564
            author=b'author <author@example.com>')
 
565
        remote = ControlDir.open(self.remote_url)
 
566
        self.assertEqual('master', remote.open_branch().nick)