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

  • Committer: Jelmer Vernooij
  • Date: 2018-03-22 23:28:30 UTC
  • mto: (0.200.1883 work)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180322232830-fy9mychr0f8s7hn2
Various fixes for annotated tags and symrefs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from __future__ import absolute_import
20
20
 
21
21
import os
 
22
import time
22
23
 
23
24
from ....controldir import ControlDir
24
25
from ....errors import (
40
41
    RemoteGitBranchFormat,
41
42
    )
42
43
 
 
44
from dulwich import porcelain
43
45
from dulwich.repo import Repo as GitRepo
44
46
 
45
47
 
146
148
                 'another': default_mapping.revision_id_foreign_to_bzr(c2)},
147
149
                local_branch.tags.get_tag_dict())
148
150
 
 
151
    def test_sprout_with_annotated_tag(self):
 
152
        c1 = self.remote_real.do_commit(
 
153
                message='message',
 
154
                committer='committer <committer@example.com>',
 
155
                author='author <author@example.com>')
 
156
        c2 = self.remote_real.do_commit(
 
157
                message='another commit',
 
158
                committer='committer <committer@example.com>',
 
159
                author='author <author@example.com>',
 
160
                ref='refs/heads/another')
 
161
        porcelain.tag_create(
 
162
                self.remote_real,
 
163
                tag="blah",
 
164
                author='author <author@example.com>',
 
165
                objectish=c2,
 
166
                tag_time=int(time.time()),
 
167
                tag_timezone=0,
 
168
                annotated=True,
 
169
                message="Annotated tag")
 
170
 
 
171
        remote = ControlDir.open(self.remote_url)
 
172
        self.make_controldir('local', format=self._to_format)
 
173
        local = remote.sprout('local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
 
174
        local_branch = local.open_branch()
 
175
        self.assertEqual(
 
176
                default_mapping.revision_id_foreign_to_bzr(c1),
 
177
                local_branch.last_revision())
 
178
        self.assertEqual(
 
179
                {'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
 
180
                local_branch.tags.get_tag_dict())
 
181
 
149
182
 
150
183
class FetchFromRemoteToBzrTests(FetchFromRemoteTestBase,TestCaseWithTransport):
151
184
 
186
219
        wt.branch.get_config_stack().set('branch.fetch_tags', True)
187
220
 
188
221
        if self._from_format == 'git':
189
 
            wt.branch.push(remote.open_branch())
 
222
            wt.branch.push(remote.create_branch('newbranch'))
190
223
        else:
191
 
            wt.branch.push(remote.open_branch(), lossy=True)
 
224
            wt.branch.push(remote.create_branch('newbranch'), lossy=True)
192
225
 
193
 
        self.assertNotEqual(self.remote_real.head(), c1)
194
226
        self.assertEqual(
195
227
                {'refs/heads/master': self.remote_real.head(),
196
228
                 'HEAD': self.remote_real.head(),
197
 
                 'refs/tags/sometag': self.remote_real.head(),
 
229
                 'refs/heads/newbranch': self.remote_real.refs['refs/heads/newbranch'],
 
230
                 'refs/tags/sometag': self.remote_real.refs['refs/heads/newbranch'],
198
231
                },
199
232
                self.remote_real.get_refs())
200
233
 
251
284
 
252
285
        remote = ControlDir.open(self.remote_url)
253
286
        self.assertEqual(
254
 
                ['', 'blah', 'master'],
 
287
                ['master', 'blah', 'master'],
255
288
                [b.name for b in remote.list_branches()])
256
289
 
257
290
    def test_get_branches(self):
267
300
 
268
301
        remote = ControlDir.open(self.remote_url)
269
302
        self.assertEqual(
270
 
                {'', 'blah', 'master'},
271
 
                set(remote.get_branches().keys()))
 
303
                {'': 'master', 'blah': 'blah', 'master': 'master'},
 
304
                {n: b.name for (n, b) in remote.get_branches().items()})
272
305
 
273
306
    def test_remove_tag(self):
274
307
        c1 = self.remote_real.do_commit(
310
343
                 'refs/tags/blah': c1,
311
344
                 'HEAD': self.remote_real.head(),
312
345
                })
 
346
 
 
347
    def test_annotated_tag(self):
 
348
        c1 = self.remote_real.do_commit(
 
349
                message='message',
 
350
                committer='committer <committer@example.com>',
 
351
                author='author <author@example.com>')
 
352
        c2 = self.remote_real.do_commit(
 
353
                message='another commit',
 
354
                committer='committer <committer@example.com>',
 
355
                author='author <author@example.com>')
 
356
 
 
357
        porcelain.tag_create(
 
358
                self.remote_real,
 
359
                tag="blah",
 
360
                author='author <author@example.com>',
 
361
                objectish=c2,
 
362
                tag_time=int(time.time()),
 
363
                tag_timezone=0,
 
364
                annotated=True,
 
365
                message="Annotated tag")
 
366
 
 
367
        remote = ControlDir.open(self.remote_url)
 
368
        remote_branch = remote.open_branch()
 
369
        self.assertEqual({
 
370
            'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
 
371
            remote_branch.tags.get_tag_dict())
 
372
 
 
373
    def tetst_get_branch_reference(self):
 
374
        c1 = self.remote_real.do_commit(
 
375
                message='message',
 
376
                committer='committer <committer@example.com>',
 
377
                author='author <author@example.com>')
 
378
        c2 = self.remote_real.do_commit(
 
379
                message='another commit',
 
380
                committer='committer <committer@example.com>',
 
381
                author='author <author@example.com>')
 
382
 
 
383
        remote = ControlDir.open(self.remote_url)
 
384
        self.assertEqual('refs/heads/master', remote.get_branch_reference(''))
 
385
        self.assertEqual(None, remote.get_branch_reference('master'))