/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.358.2 by Jelmer Vernooij
Refresh copyright headers, add my email.
1
# Copyright (C) 2010-2018 Jelmer Vernooij <jelmer@jelmer.uk>
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
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
0.358.1 by Jelmer Vernooij
Fix FSF address.
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
16
17
"""Test the smart client."""
18
0.358.3 by Jelmer Vernooij
Enable absolute import.
19
from __future__ import absolute_import
20
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
21
from io import BytesIO
0.406.3 by Jelmer Vernooij
Add extra tests.
22
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
23
import os
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
24
import time
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
25
26
from ....controldir import ControlDir
0.200.1642 by Jelmer Vernooij
Use relative imports in tests.
27
from ....errors import (
0.200.1275 by Jelmer Vernooij
recognize missing repositories
28
    BzrError,
0.404.5 by Jelmer Vernooij
Check for diverged branches during push.
29
    DivergedBranches,
0.200.1275 by Jelmer Vernooij
recognize missing repositories
30
    NotBranchError,
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
31
    NoSuchTag,
0.200.1275 by Jelmer Vernooij
recognize missing repositories
32
    )
33
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
34
from ....tests import (
35
    TestCase,
36
    TestCaseWithTransport,
37
    )
38
from ....tests.features import ExecutableFeature
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
39
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
40
from ..mapping import default_mapping
0.200.1642 by Jelmer Vernooij
Use relative imports in tests.
41
from ..remote import (
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
42
    split_git_url,
0.200.1275 by Jelmer Vernooij
recognize missing repositories
43
    parse_git_error,
0.295.1 by Jelmer Vernooij
Split up branch formats.
44
    RemoteGitBranchFormat,
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
45
    )
46
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
47
from dulwich import porcelain
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
48
from dulwich.repo import Repo as GitRepo
49
50
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
51
class SplitUrlTests(TestCase):
52
53
    def test_simple(self):
6964.2.3 by Jelmer Vernooij
Review comments.
54
        self.assertEqual(("foo", None, None, "/bar"),
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
55
            split_git_url("git://foo/bar"))
56
57
    def test_port(self):
6964.2.3 by Jelmer Vernooij
Review comments.
58
        self.assertEqual(("foo", 343, None, "/bar"),
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
59
            split_git_url("git://foo:343/bar"))
60
61
    def test_username(self):
6964.2.3 by Jelmer Vernooij
Review comments.
62
        self.assertEqual(("foo", None, "la", "/bar"),
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
63
            split_git_url("git://la@foo/bar"))
64
65
    def test_nopath(self):
6964.2.3 by Jelmer Vernooij
Review comments.
66
        self.assertEqual(("foo", None, None, "/"),
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
67
            split_git_url("git://foo/"))
68
69
    def test_slashpath(self):
6964.2.3 by Jelmer Vernooij
Review comments.
70
        self.assertEqual(("foo", None, None, "//bar"),
0.200.709 by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour.
71
            split_git_url("git://foo//bar"))
0.246.2 by Jelmer Vernooij
Improve the fix dealing with git repo's in home directories.
72
73
    def test_homedir(self):
6964.2.3 by Jelmer Vernooij
Review comments.
74
        self.assertEqual(("foo", None, None, "~bar"),
0.246.2 by Jelmer Vernooij
Improve the fix dealing with git repo's in home directories.
75
            split_git_url("git://foo/~bar"))
0.200.1275 by Jelmer Vernooij
recognize missing repositories
76
77
78
class ParseGitErrorTests(TestCase):
79
80
    def test_unknown(self):
81
        e = parse_git_error("url", "foo")
82
        self.assertIsInstance(e, BzrError)
83
84
    def test_notbrancherror(self):
85
        e = parse_git_error("url", "\n Could not find Repository foo/bar")
86
        self.assertIsInstance(e, NotBranchError)
0.295.1 by Jelmer Vernooij
Split up branch formats.
87
88
89
class TestRemoteGitBranchFormat(TestCase):
90
91
    def setUp(self):
92
        super(TestRemoteGitBranchFormat, self).setUp()
93
        self.format = RemoteGitBranchFormat()
94
95
    def test_get_format_description(self):
6964.2.3 by Jelmer Vernooij
Review comments.
96
        self.assertEqual("Remote Git Branch", self.format.get_format_description())
0.295.1 by Jelmer Vernooij
Split up branch formats.
97
98
    def test_get_network_name(self):
6973.13.2 by Jelmer Vernooij
Fix some more tests.
99
        self.assertEqual(b"git", self.format.network_name())
0.295.1 by Jelmer Vernooij
Split up branch formats.
100
101
    def test_supports_tags(self):
102
        self.assertTrue(self.format.supports_tags())
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
103
104
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
105
class FetchFromRemoteTestBase(object):
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
106
107
    _test_needs_features = [ExecutableFeature('git')]
108
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
109
    _to_format = None
110
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
111
    def setUp(self):
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
112
        TestCaseWithTransport.setUp(self)
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
113
        self.remote_real = GitRepo.init('remote', mkdir=True)
114
        self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
115
        self.permit_url(self.remote_url)
116
117
    def test_sprout_simple(self):
118
        self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
119
                message=b'message',
120
                committer=b'committer <committer@example.com>',
121
                author=b'author <author@example.com>')
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
122
123
        remote = ControlDir.open(self.remote_url)
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
124
        self.make_controldir('local', format=self._to_format)
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
125
        local = remote.sprout('local')
126
        self.assertEqual(
127
                default_mapping.revision_id_foreign_to_bzr(self.remote_real.head()),
128
                local.open_branch().last_revision())
129
130
    def test_sprout_with_tags(self):
131
        c1 = self.remote_real.do_commit(
7018.3.8 by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport.
132
                message=b'message',
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
133
                committer=b'committer <committer@example.com>',
134
                author=b'author <author@example.com>')
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
135
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
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')
7018.3.8 by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport.
140
        self.remote_real.refs[b'refs/tags/blah'] = self.remote_real.head()
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
141
142
        remote = ControlDir.open(self.remote_url)
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
143
        self.make_controldir('local', format=self._to_format)
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
144
        local = remote.sprout('local')
145
        local_branch = local.open_branch()
146
        self.assertEqual(
147
                default_mapping.revision_id_foreign_to_bzr(c1),
148
                local_branch.last_revision())
149
        self.assertEqual(
150
                {'blah': local_branch.last_revision(),
151
                 'another': default_mapping.revision_id_foreign_to_bzr(c2)},
152
                local_branch.tags.get_tag_dict())
153
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
154
    def test_sprout_with_annotated_tag(self):
155
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
156
                message=b'message',
157
                committer=b'committer <committer@example.com>',
158
                author=b'author <author@example.com>')
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
159
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
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')
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
164
        porcelain.tag_create(
165
                self.remote_real,
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
166
                tag=b"blah",
167
                author=b'author <author@example.com>',
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
168
                objectish=c2,
169
                tag_time=int(time.time()),
170
                tag_timezone=0,
171
                annotated=True,
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
172
                message=b"Annotated tag")
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
173
174
        remote = ControlDir.open(self.remote_url)
175
        self.make_controldir('local', format=self._to_format)
176
        local = remote.sprout('local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
177
        local_branch = local.open_branch()
178
        self.assertEqual(
179
                default_mapping.revision_id_foreign_to_bzr(c1),
180
                local_branch.last_revision())
181
        self.assertEqual(
182
                {'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
183
                local_branch.tags.get_tag_dict())
184
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
185
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
186
class FetchFromRemoteToBzrTests(FetchFromRemoteTestBase,TestCaseWithTransport):
187
188
    _to_format = '2a'
189
190
191
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase,TestCaseWithTransport):
192
193
    _to_format = 'git'
194
195
196
class PushToRemoteBase(object):
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
197
198
    _test_needs_features = [ExecutableFeature('git')]
199
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
200
    _from_format = None
201
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
202
    def setUp(self):
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
203
        TestCaseWithTransport.setUp(self)
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
204
        self.remote_real = GitRepo.init('remote', mkdir=True)
205
        self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
206
        self.permit_url(self.remote_url)
207
0.403.3 by Jelmer Vernooij
Test RemoteGitDir.push_branch.
208
    def test_push_branch_new(self):
209
        remote = ControlDir.open(self.remote_url)
210
        wt = self.make_branch_and_tree('local', format=self._from_format)
211
        self.build_tree(['local/blah'])
212
        wt.add(['blah'])
213
        revid = wt.commit('blah')
214
215
        if self._from_format == 'git':
0.406.2 by Jelmer Vernooij
Add tests.
216
            result = remote.push_branch(wt.branch, name='newbranch')
217
        else:
218
            result = remote.push_branch(wt.branch, lossy=True, name='newbranch')
219
220
        self.assertEqual(0, result.old_revno)
221
        if self._from_format == 'git':
222
            self.assertEqual(1, result.new_revno)
223
        else:
224
            self.assertIs(None, result.new_revno)
0.403.3 by Jelmer Vernooij
Test RemoteGitDir.push_branch.
225
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
226
        result.report(BytesIO())
0.406.3 by Jelmer Vernooij
Add extra tests.
227
0.403.3 by Jelmer Vernooij
Test RemoteGitDir.push_branch.
228
        self.assertEqual(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
229
                {b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'],
0.403.3 by Jelmer Vernooij
Test RemoteGitDir.push_branch.
230
                },
231
                self.remote_real.get_refs())
232
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
233
    def test_push(self):
234
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
235
                message=b'message',
236
                committer=b'committer <committer@example.com>',
237
                author=b'author <author@example.com>')
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
238
239
        remote = ControlDir.open(self.remote_url)
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
240
        self.make_controldir('local', format=self._from_format)
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
241
        local = remote.sprout('local')
242
        self.build_tree(['local/blah'])
243
        wt = local.open_workingtree()
244
        wt.add(['blah'])
245
        revid = wt.commit('blah')
246
        wt.branch.tags.set_tag('sometag', revid)
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
247
        wt.branch.get_config_stack().set('branch.fetch_tags', True)
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
248
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
249
        if self._from_format == 'git':
0.406.2 by Jelmer Vernooij
Add tests.
250
            result = wt.branch.push(remote.create_branch('newbranch'))
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
251
        else:
0.406.2 by Jelmer Vernooij
Add tests.
252
            result = wt.branch.push(remote.create_branch('newbranch'), lossy=True)
253
254
        self.assertEqual(0, result.old_revno)
255
        self.assertEqual(2, result.new_revno)
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
256
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
257
        result.report(BytesIO())
0.406.3 by Jelmer Vernooij
Add extra tests.
258
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
259
        self.assertEqual(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
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'],
0.376.1 by Jelmer Vernooij
Add tests for remote operations.
264
                },
265
                self.remote_real.get_refs())
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
266
0.404.5 by Jelmer Vernooij
Check for diverged branches during push.
267
    def test_push_diverged(self):
268
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
269
                message=b'message',
270
                committer=b'committer <committer@example.com>',
271
                author=b'author <author@example.com>',
272
                ref=b'refs/heads/newbranch')
0.404.5 by Jelmer Vernooij
Check for diverged branches during push.
273
274
        remote = ControlDir.open(self.remote_url)
275
        wt = self.make_branch_and_tree('local', format=self._from_format)
276
        self.build_tree(['local/blah'])
277
        wt.add(['blah'])
278
        revid = wt.commit('blah')
279
280
        newbranch = remote.open_branch('newbranch')
281
        if self._from_format == 'git':
282
            self.assertRaises(DivergedBranches, wt.branch.push, newbranch)
283
        else:
284
            self.assertRaises(DivergedBranches, wt.branch.push, newbranch, lossy=True)
285
286
        self.assertEqual(
7018.3.2 by Jelmer Vernooij
Fix some git tests.
287
                {b'refs/heads/newbranch': c1 },
0.404.5 by Jelmer Vernooij
Check for diverged branches during push.
288
                self.remote_real.get_refs())
289
290
        if self._from_format == 'git':
291
            wt.branch.push(newbranch, overwrite=True)
292
        else:
293
            wt.branch.push(newbranch, lossy=True, overwrite=True)
294
7018.3.8 by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport.
295
        self.assertNotEqual(c1, self.remote_real.refs[b'refs/heads/newbranch'])
0.404.5 by Jelmer Vernooij
Check for diverged branches during push.
296
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
297
298
class PushToRemoteFromBzrTests(PushToRemoteBase,TestCaseWithTransport):
299
300
    _from_format = '2a'
301
302
303
class PushToRemoteFromGitTests(PushToRemoteBase,TestCaseWithTransport):
304
305
    _from_format = 'git'
306
307
308
class RemoteControlDirTests(TestCaseWithTransport):
309
310
    _test_needs_features = [ExecutableFeature('git')]
311
312
    def setUp(self):
313
        TestCaseWithTransport.setUp(self)
314
        self.remote_real = GitRepo.init('remote', mkdir=True)
315
        self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path)
316
        self.permit_url(self.remote_url)
317
318
    def test_remove_branch(self):
319
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
320
                message=b'message',
321
                committer=b'committer <committer@example.com>',
322
                author=b'author <author@example.com>')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
323
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
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')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
328
329
        remote = ControlDir.open(self.remote_url)
330
        remote.destroy_branch(name='blah')
331
        self.assertEqual(
332
                self.remote_real.get_refs(),
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
333
                {b'refs/heads/master': self.remote_real.head(),
334
                 b'HEAD': self.remote_real.head(),
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
335
                })
336
337
    def test_list_branches(self):
338
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
339
                message=b'message',
340
                committer=b'committer <committer@example.com>',
341
                author=b'author <author@example.com>')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
342
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
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')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
347
348
        remote = ControlDir.open(self.remote_url)
349
        self.assertEqual(
6997.1.1 by Jelmer Vernooij
Fix tests on Python3.5.
350
                set(['master', 'blah', 'master']),
351
                set([b.name for b in remote.list_branches()]))
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
352
353
    def test_get_branches(self):
354
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
355
                message=b'message',
356
                committer=b'committer <committer@example.com>',
357
                author=b'author <author@example.com>')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
358
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
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')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
363
364
        remote = ControlDir.open(self.remote_url)
365
        self.assertEqual(
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
366
                {'': 'master', 'blah': 'blah', 'master': 'master'},
367
                {n: b.name for (n, b) in remote.get_branches().items()})
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
368
369
    def test_remove_tag(self):
370
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
371
                message=b'message',
372
                committer=b'committer <committer@example.com>',
373
                author=b'author <author@example.com>')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
374
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
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')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
379
380
        remote = ControlDir.open(self.remote_url)
381
        remote_branch = remote.open_branch()
382
        remote_branch.tags.delete_tag('blah')
383
        self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah')
384
        self.assertEqual(
385
                self.remote_real.get_refs(),
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
386
                {b'refs/heads/master': self.remote_real.head(),
387
                 b'HEAD': self.remote_real.head(),
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
388
                })
389
390
    def test_set_tag(self):
391
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
392
                message=b'message',
393
                committer=b'committer <committer@example.com>',
394
                author=b'author <author@example.com>')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
395
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
396
                message=b'another commit',
397
                committer=b'committer <committer@example.com>',
398
                author=b'author <author@example.com>')
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
399
400
        remote = ControlDir.open(self.remote_url)
401
        remote.open_branch().tags.set_tag(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
402
            b'blah', default_mapping.revision_id_foreign_to_bzr(c1))
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
403
        self.assertEqual(
404
                self.remote_real.get_refs(),
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
405
                {b'refs/heads/master': self.remote_real.head(),
406
                 b'refs/tags/blah': c1,
407
                 b'HEAD': self.remote_real.head(),
0.377.1 by Jelmer Vernooij
Fix some remote operations and add more tests.
408
                })
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
409
410
    def test_annotated_tag(self):
411
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
412
                message=b'message',
413
                committer=b'committer <committer@example.com>',
414
                author=b'author <author@example.com>')
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
415
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
416
                message=b'another commit',
417
                committer=b'committer <committer@example.com>',
418
                author=b'author <author@example.com>')
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
419
420
        porcelain.tag_create(
421
                self.remote_real,
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
422
                tag=b"blah",
423
                author=b'author <author@example.com>',
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
424
                objectish=c2,
425
                tag_time=int(time.time()),
426
                tag_timezone=0,
427
                annotated=True,
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
428
                message=b"Annotated tag")
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
429
430
        remote = ControlDir.open(self.remote_url)
431
        remote_branch = remote.open_branch()
432
        self.assertEqual({
6973.13.2 by Jelmer Vernooij
Fix some more tests.
433
            'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
434
            remote_branch.tags.get_tag_dict())
435
436
    def tetst_get_branch_reference(self):
437
        c1 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
438
                message=b'message',
439
                committer=b'committer <committer@example.com>',
440
                author=b'author <author@example.com>')
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
441
        c2 = self.remote_real.do_commit(
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
442
                message=b'another commit',
443
                committer=b'committer <committer@example.com>',
444
                author=b'author <author@example.com>')
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
445
446
        remote = ControlDir.open(self.remote_url)
6964.2.1 by Jelmer Vernooij
Initial work to support brz-git on python3.
447
        self.assertEqual(b'refs/heads/master', remote.get_branch_reference(''))
0.382.1 by Jelmer Vernooij
Various fixes for annotated tags and symrefs.
448
        self.assertEqual(None, remote.get_branch_reference('master'))