~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_sprout.py

  • Committer: Patch Queue Manager
  • Date: 2016-01-31 13:36:59 UTC
  • mfrom: (6613.1.5 1538480-match-hostname)
  • Revision ID: pqm@pqm.ubuntu.com-20160131133659-ouy92ee2wlv9xz8m
(vila) Use ssl.match_hostname instead of our own. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    revision as _mod_revision,
26
26
    tests,
27
27
    )
 
28
from bzrlib.tests import (
 
29
    features,
 
30
    )
28
31
from bzrlib.tests.per_branch import TestCaseWithBranch
29
32
 
30
33
 
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',
56
 
                                                         format='metaweave')
 
59
                                                         format='knit')
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())
 
116
 
 
117
    def test_sprout_preserves_tags(self):
 
118
        """Sprout preserves tags, even tags of absent revisions."""
 
119
        try:
 
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()
 
125
        try:
 
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'))
113
135
 
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')
129
151
 
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)
137
159
 
138
160
        tree = self.make_branch_and_tree('tree1')
139
161
 
157
179
 
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)
161
186
        tree.add('')
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.")
188
213
            else:
189
214
                raise
190
215
        result = dir.open_branch()