55
55
def test_simple(self):
56
56
self.assertEqual(("foo", None, None, "/bar"),
57
split_git_url("git://foo/bar"))
57
split_git_url("git://foo/bar"))
59
59
def test_port(self):
60
60
self.assertEqual(("foo", 343, None, "/bar"),
61
split_git_url("git://foo:343/bar"))
61
split_git_url("git://foo:343/bar"))
63
63
def test_username(self):
64
64
self.assertEqual(("foo", None, "la", "/bar"),
65
split_git_url("git://la@foo/bar"))
65
split_git_url("git://la@foo/bar"))
67
67
def test_nopath(self):
68
68
self.assertEqual(("foo", None, None, "/"),
69
split_git_url("git://foo/"))
69
split_git_url("git://foo/"))
71
71
def test_slashpath(self):
72
72
self.assertEqual(("foo", None, None, "//bar"),
73
split_git_url("git://foo//bar"))
73
split_git_url("git://foo//bar"))
75
75
def test_homedir(self):
76
76
self.assertEqual(("foo", None, None, "~bar"),
77
split_git_url("git://foo/~bar"))
77
split_git_url("git://foo/~bar"))
80
80
class ParseGitErrorTests(TestCase):
186
188
def test_sprout_simple(self):
187
189
self.remote_real.do_commit(
189
committer=b'committer <committer@example.com>',
190
author=b'author <author@example.com>')
191
committer=b'committer <committer@example.com>',
192
author=b'author <author@example.com>')
192
194
remote = ControlDir.open(self.remote_url)
193
195
self.make_controldir('local', format=self._to_format)
194
196
local = remote.sprout('local')
195
197
self.assertEqual(
196
default_mapping.revision_id_foreign_to_bzr(self.remote_real.head()),
197
local.open_branch().last_revision())
198
default_mapping.revision_id_foreign_to_bzr(
199
self.remote_real.head()),
200
local.open_branch().last_revision())
199
202
def test_sprout_with_tags(self):
200
203
c1 = self.remote_real.do_commit(
202
committer=b'committer <committer@example.com>',
203
author=b'author <author@example.com>')
205
committer=b'committer <committer@example.com>',
206
author=b'author <author@example.com>')
204
207
c2 = self.remote_real.do_commit(
205
message=b'another commit',
206
committer=b'committer <committer@example.com>',
207
author=b'author <author@example.com>',
208
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')
209
212
self.remote_real.refs[b'refs/tags/blah'] = self.remote_real.head()
211
214
remote = ControlDir.open(self.remote_url)
213
216
local = remote.sprout('local')
214
217
local_branch = local.open_branch()
215
218
self.assertEqual(
216
default_mapping.revision_id_foreign_to_bzr(c1),
217
local_branch.last_revision())
219
default_mapping.revision_id_foreign_to_bzr(c1),
220
local_branch.last_revision())
218
221
self.assertEqual(
219
{'blah': local_branch.last_revision(),
220
'another': default_mapping.revision_id_foreign_to_bzr(c2)},
221
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())
223
226
def test_sprout_with_annotated_tag(self):
224
227
c1 = self.remote_real.do_commit(
226
committer=b'committer <committer@example.com>',
227
author=b'author <author@example.com>')
229
committer=b'committer <committer@example.com>',
230
author=b'author <author@example.com>')
228
231
c2 = self.remote_real.do_commit(
229
message=b'another commit',
230
committer=b'committer <committer@example.com>',
231
author=b'author <author@example.com>',
232
ref=b'refs/heads/another')
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')
233
236
porcelain.tag_create(
236
author=b'author <author@example.com>',
238
tag_time=int(time.time()),
241
message=b"Annotated tag")
239
author=b'author <author@example.com>',
241
tag_time=int(time.time()),
244
message=b"Annotated tag")
243
246
remote = ControlDir.open(self.remote_url)
244
247
self.make_controldir('local', format=self._to_format)
245
local = remote.sprout('local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
248
local = remote.sprout(
249
'local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1))
246
250
local_branch = local.open_branch()
247
251
self.assertEqual(
248
default_mapping.revision_id_foreign_to_bzr(c1),
249
local_branch.last_revision())
252
default_mapping.revision_id_foreign_to_bzr(c1),
253
local_branch.last_revision())
250
254
self.assertEqual(
251
255
{'blah': default_mapping.revision_id_foreign_to_bzr(c2)},
252
256
local_branch.tags.get_tag_dict())
419
426
def test_remove_branch(self):
420
427
c1 = self.remote_real.do_commit(
422
committer=b'committer <committer@example.com>',
423
author=b'author <author@example.com>')
429
committer=b'committer <committer@example.com>',
430
author=b'author <author@example.com>')
424
431
c2 = self.remote_real.do_commit(
425
message=b'another commit',
426
committer=b'committer <committer@example.com>',
427
author=b'author <author@example.com>',
428
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')
430
437
remote = ControlDir.open(self.remote_url)
431
438
remote.destroy_branch(name='blah')
432
439
self.assertEqual(
433
self.remote_real.get_refs(),
434
{b'refs/heads/master': self.remote_real.head(),
435
b'HEAD': self.remote_real.head(),
440
self.remote_real.get_refs(),
441
{b'refs/heads/master': self.remote_real.head(),
442
b'HEAD': self.remote_real.head(),
438
445
def test_list_branches(self):
439
446
c1 = self.remote_real.do_commit(
441
committer=b'committer <committer@example.com>',
442
author=b'author <author@example.com>')
448
committer=b'committer <committer@example.com>',
449
author=b'author <author@example.com>')
443
450
c2 = self.remote_real.do_commit(
444
message=b'another commit',
445
committer=b'committer <committer@example.com>',
446
author=b'author <author@example.com>',
447
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')
449
456
remote = ControlDir.open(self.remote_url)
450
457
self.assertEqual(
451
set(['master', 'blah', 'master']),
452
set([b.name for b in remote.list_branches()]))
458
set(['master', 'blah', 'master']),
459
set([b.name for b in remote.list_branches()]))
454
461
def test_get_branches(self):
455
462
c1 = self.remote_real.do_commit(
457
committer=b'committer <committer@example.com>',
458
author=b'author <author@example.com>')
464
committer=b'committer <committer@example.com>',
465
author=b'author <author@example.com>')
459
466
c2 = self.remote_real.do_commit(
460
message=b'another commit',
461
committer=b'committer <committer@example.com>',
462
author=b'author <author@example.com>',
463
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')
465
472
remote = ControlDir.open(self.remote_url)
466
473
self.assertEqual(
467
{'': 'master', 'blah': 'blah', 'master': 'master'},
468
{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()})
470
477
def test_remove_tag(self):
471
478
c1 = self.remote_real.do_commit(
473
committer=b'committer <committer@example.com>',
474
author=b'author <author@example.com>')
480
committer=b'committer <committer@example.com>',
481
author=b'author <author@example.com>')
475
482
c2 = self.remote_real.do_commit(
476
message=b'another commit',
477
committer=b'committer <committer@example.com>',
478
author=b'author <author@example.com>',
479
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')
481
488
remote = ControlDir.open(self.remote_url)
482
489
remote_branch = remote.open_branch()
483
490
remote_branch.tags.delete_tag('blah')
484
491
self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah')
485
492
self.assertEqual(
486
self.remote_real.get_refs(),
487
{b'refs/heads/master': self.remote_real.head(),
488
b'HEAD': self.remote_real.head(),
493
self.remote_real.get_refs(),
494
{b'refs/heads/master': self.remote_real.head(),
495
b'HEAD': self.remote_real.head(),
491
498
def test_set_tag(self):
492
499
c1 = self.remote_real.do_commit(
494
committer=b'committer <committer@example.com>',
495
author=b'author <author@example.com>')
501
committer=b'committer <committer@example.com>',
502
author=b'author <author@example.com>')
496
503
c2 = self.remote_real.do_commit(
497
message=b'another commit',
498
committer=b'committer <committer@example.com>',
499
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>')
501
508
remote = ControlDir.open(self.remote_url)
502
509
remote.open_branch().tags.set_tag(
503
510
b'blah', default_mapping.revision_id_foreign_to_bzr(c1))
504
511
self.assertEqual(
505
self.remote_real.get_refs(),
506
{b'refs/heads/master': self.remote_real.head(),
507
b'refs/tags/blah': c1,
508
b'HEAD': self.remote_real.head(),
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(),
511
518
def test_annotated_tag(self):
512
519
c1 = self.remote_real.do_commit(
514
committer=b'committer <committer@example.com>',
515
author=b'author <author@example.com>')
521
committer=b'committer <committer@example.com>',
522
author=b'author <author@example.com>')
516
523
c2 = self.remote_real.do_commit(
517
message=b'another commit',
518
committer=b'committer <committer@example.com>',
519
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>')
521
528
porcelain.tag_create(
524
author=b'author <author@example.com>',
526
tag_time=int(time.time()),
529
message=b"Annotated tag")
531
author=b'author <author@example.com>',
533
tag_time=int(time.time()),
536
message=b"Annotated tag")
531
538
remote = ControlDir.open(self.remote_url)
532
539
remote_branch = remote.open_branch()