669
673
target = dir.sprout(self.get_url('target'), revision_id='1')
670
674
self.assertEqual('1', target.open_branch().last_revision())
676
def test_sprout_bzrdir_branch_with_tags(self):
677
# when sprouting a branch all revisions named in the tags are copied
679
builder = self.make_branch_builder('source')
680
source = fixtures.build_branch_with_non_ancestral_rev(builder)
682
source.tags.set_tag('tag-a', 'rev-2')
683
except errors.TagsNotSupported:
684
raise TestNotApplicable('Branch format does not support tags.')
685
# Now source has a tag not in its ancestry. Sprout its controldir.
687
target = dir.sprout(self.get_url('target'))
688
# The tag is present, and so is its revision.
689
new_branch = target.open_branch()
690
self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a'))
691
new_branch.repository.get_revision('rev-2')
693
def test_sprout_bzrdir_branch_with_absent_tag(self):
694
# tags referencing absent revisions are copied (and those absent
695
# revisions do not prevent the sprout.)
696
builder = self.make_branch_builder('source')
697
builder.build_commit(message="Rev 1", rev_id='rev-1')
698
source = builder.get_branch()
700
source.tags.set_tag('tag-a', 'missing-rev')
701
except errors.TagsNotSupported:
702
raise TestNotApplicable('Branch format does not support tags.')
703
# Now source has a tag pointing to an absent revision. Sprout its
706
target = dir.sprout(self.get_url('target'))
707
# The tag is present in the target
708
new_branch = target.open_branch()
709
self.assertEqual('missing-rev', new_branch.tags.lookup_tag('tag-a'))
711
def test_sprout_bzrdir_passing_source_branch_with_absent_tag(self):
712
# tags referencing absent revisions are copied (and those absent
713
# revisions do not prevent the sprout.)
714
builder = self.make_branch_builder('source')
715
builder.build_commit(message="Rev 1", rev_id='rev-1')
716
source = builder.get_branch()
718
source.tags.set_tag('tag-a', 'missing-rev')
719
except errors.TagsNotSupported:
720
raise TestNotApplicable('Branch format does not support tags.')
721
# Now source has a tag pointing to an absent revision. Sprout its
724
target = dir.sprout(self.get_url('target'), source_branch=source)
725
# The tag is present in the target
726
new_branch = target.open_branch()
727
self.assertEqual('missing-rev', new_branch.tags.lookup_tag('tag-a'))
729
def test_sprout_bzrdir_passing_rev_not_source_branch_copies_tags(self):
730
# dir.sprout(..., revision_id='rev1') copies rev1, and all the tags of
731
# the branch at that bzrdir, the ancestry of all of those, but no other
732
# revs (not even the tip of the source branch).
733
builder = self.make_branch_builder('source')
734
builder.build_commit(message="Base", rev_id='base-rev')
735
# Make three parallel lines of ancestry off this base.
736
source = builder.get_branch()
737
builder.build_commit(message="Rev A1", rev_id='rev-a1')
738
builder.build_commit(message="Rev A2", rev_id='rev-a2')
739
builder.build_commit(message="Rev A3", rev_id='rev-a3')
740
source.set_last_revision_info(1, 'base-rev')
741
builder.build_commit(message="Rev B1", rev_id='rev-b1')
742
builder.build_commit(message="Rev B2", rev_id='rev-b2')
743
builder.build_commit(message="Rev B3", rev_id='rev-b3')
744
source.set_last_revision_info(1, 'base-rev')
745
builder.build_commit(message="Rev C1", rev_id='rev-c1')
746
builder.build_commit(message="Rev C2", rev_id='rev-c2')
747
builder.build_commit(message="Rev C3", rev_id='rev-c3')
748
# Set the branch tip to A2
749
source.set_last_revision_info(3, 'rev-a2')
751
# Create a tag for B2, and for an absent rev
752
source.tags.set_tag('tag-non-ancestry', 'rev-b2')
753
source.tags.set_tag('tag-absent', 'absent-rev')
754
except errors.TagsNotSupported:
755
raise TestNotApplicable('Branch format does not support tags.')
756
# And ask sprout for C2
758
target = dir.sprout(self.get_url('target'), revision_id='rev-c2')
759
# The tags are present
760
new_branch = target.open_branch()
762
{'tag-absent': 'absent-rev', 'tag-non-ancestry': 'rev-b2'},
763
new_branch.tags.get_tag_dict())
764
# And the revs for A2, B2 and C2's ancestries are present, but no
767
['base-rev', 'rev-b1', 'rev-b2', 'rev-c1', 'rev-c2'],
768
sorted(new_branch.repository.all_revision_ids()))
672
770
def test_sprout_bzrdir_tree_branch_reference(self):
673
771
# sprouting should create a repository if needed and a sprouted branch.
674
772
# the tree state should not be copied.