53
56
# Start with a format that is unlikely to be the target format
54
57
# We call the super class to allow overriding the format of creation)
55
58
source = tests.TestCaseWithTransport.make_branch(self, 'old-branch',
57
60
target_bzrdir = self.make_bzrdir('target')
58
61
target_bzrdir.create_repository()
59
62
result_format = self.branch_format
109
112
repo.fetch(wt.branch.repository)
110
113
branch2 = wt.branch.sprout(repo.bzrdir, revision_id='rev2-alt')
111
114
self.assertEqual((2, 'rev2-alt'), branch2.last_revision_info())
112
self.assertEqual(['rev1', 'rev2-alt'], branch2.revision_history())
115
self.assertEqual('rev2-alt', branch2.last_revision())
117
def test_sprout_preserves_tags(self):
118
"""Sprout preserves tags, even tags of absent revisions."""
120
builder = self.make_branch_builder('source')
121
except errors.UninitializableFormat:
122
raise tests.TestSkipped('Uninitializable branch format')
123
builder.build_commit(message="Rev 1", rev_id='rev-1')
124
source = builder.get_branch()
126
source.tags.set_tag('tag-a', 'missing-rev')
127
except (errors.TagsNotSupported, errors.GhostTagsNotSupported):
128
raise tests.TestNotApplicable(
129
'Branch format does not support tags or tags to ghosts.')
130
# Now source has a tag pointing to an absent revision. Sprout it.
131
target_bzrdir = self.make_repository('target').bzrdir
132
new_branch = source.sprout(target_bzrdir)
133
# The tag is present in the target
134
self.assertEqual('missing-rev', new_branch.tags.lookup_tag('tag-a'))
114
136
def test_sprout_from_any_repo_revision(self):
115
137
"""We should be able to sprout from any revision."""
125
147
wt2 = wt.bzrdir.sprout('target',
126
148
revision_id='rev1a').open_workingtree()
127
149
self.assertEqual('rev1a', wt2.last_revision())
128
self.failUnlessExists('target/a')
150
self.assertPathExists('target/a')
130
152
def test_sprout_with_unicode_symlink(self):
131
153
# this tests bug #272444
132
154
# Since the trigger function seems to be set_parent_trees, there exists
133
155
# also a similar test, with name test_unicode_symlink, in class
134
156
# TestSetParents at file per_workingtree/test_parents.py
135
self.requireFeature(tests.SymlinkFeature)
136
self.requireFeature(tests.UnicodeFilenameFeature)
157
self.requireFeature(features.SymlinkFeature)
158
self.requireFeature(features.UnicodeFilenameFeature)
138
160
tree = self.make_branch_and_tree('tree1')
158
180
def test_sprout_with_ghost_in_mainline(self):
159
181
tree = self.make_branch_and_tree('tree1')
182
if not tree.branch.repository._format.supports_ghosts:
183
raise tests.TestNotApplicable(
184
"repository format does not support ghosts in mainline")
160
185
tree.set_parent_ids(["spooky"], allow_leftmost_as_ghost=True)
162
187
tree.commit('msg1', rev_id='rev1')
182
207
source.last_revision(), possible_transports=[target_transport],
183
208
source_branch=source, stacked=True)
184
209
except errors.UnstackableBranchFormat:
185
if isinstance(self.branch_format, _mod_branch.BzrBranchFormat4):
186
raise tests.KnownFailure(
187
"Format 4 doesn't auto stack successfully.")
210
if not self.branch_format.supports_stacking():
211
raise tests.TestNotApplicable(
212
"Format doesn't auto stack successfully.")
190
215
result = dir.open_branch()