~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_interbranch/__init__.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:
27
27
 
28
28
from bzrlib import (
29
29
    branchbuilder,
30
 
    memorytree,
31
30
    )
32
31
from bzrlib.branch import (
33
32
                           GenericInterBranch,
34
33
                           InterBranch,
35
34
                           )
36
 
from bzrlib.bzrdir import (
37
 
    BzrDirFormat,
38
 
    BzrDirMetaFormat1,
39
 
    )
40
 
from bzrlib.errors import (
41
 
    FileExists,
42
 
    NotBranchError,
43
 
    UninitializableFormat,
44
 
    )
45
35
from bzrlib.tests import (
46
36
    TestCaseWithTransport,
47
37
    multiply_tests,
86
76
class TestCaseWithInterBranch(TestCaseWithTransport):
87
77
 
88
78
    def make_from_branch(self, relpath):
89
 
        repo = self.make_repository(relpath)
90
 
        return self.branch_format_from.initialize(repo.bzrdir)
 
79
        return self.make_branch(relpath, format=self.branch_format_from._matchingbzrdir)
91
80
 
92
81
    def make_from_branch_and_memory_tree(self, relpath):
93
82
        """Create a branch on the default transport and a MemoryTree for it."""
94
 
        b = self.make_from_branch(relpath)
95
 
        return memorytree.MemoryTree.create_on_branch(b)
 
83
        self.assertEquals(
 
84
            self.branch_format_from._matchingbzrdir.get_branch_format(),
 
85
            self.branch_format_from)
 
86
        return self.make_branch_and_memory_tree(
 
87
            relpath, format=self.branch_format_from._matchingbzrdir)
96
88
 
97
89
    def make_from_branch_and_tree(self, relpath):
98
90
        """Create a branch on the default transport and a working tree for it."""
99
 
        b = self.make_from_branch(relpath)
100
 
        return b.bzrdir.create_workingtree()
 
91
        self.assertEquals(
 
92
            self.branch_format_from._matchingbzrdir.get_branch_format(),
 
93
            self.branch_format_from)
 
94
        return self.make_branch_and_tree(relpath,
 
95
            format=self.branch_format_from._matchingbzrdir)
101
96
 
102
97
    def make_from_branch_builder(self, relpath):
103
 
        default_format = BzrDirFormat.get_default_format()
104
 
        format = BzrDirMetaFormat1()
105
 
        format.set_branch_format(self.branch_format_from)
106
 
        format.repository_format = default_format.repository_format
107
 
        format.workingtree_format = default_format.workingtree_format
 
98
        self.assertEquals(
 
99
            self.branch_format_from._matchingbzrdir.get_branch_format(),
 
100
            self.branch_format_from)
108
101
        return branchbuilder.BranchBuilder(self.get_transport(relpath),
109
 
            format=format)
 
102
            format=self.branch_format_from._matchingbzrdir)
110
103
 
111
104
    def make_to_branch(self, relpath):
112
 
        repo = self.make_repository(relpath)
113
 
        return self.branch_format_to.initialize(repo.bzrdir)
 
105
        self.assertEquals(
 
106
            self.branch_format_to._matchingbzrdir.get_branch_format(),
 
107
            self.branch_format_to)
 
108
        return self.make_branch(relpath, format=self.branch_format_to._matchingbzrdir)
114
109
 
115
110
    def make_to_branch_and_memory_tree(self, relpath):
116
111
        """Create a branch on the default transport and a MemoryTree for it."""
117
 
        b = self.make_to_branch(relpath)
118
 
        return memorytree.MemoryTree.create_on_branch(b)
 
112
        self.assertEquals(
 
113
            self.branch_format_to._matchingbzrdir.get_branch_format(),
 
114
            self.branch_format_to)
 
115
        return self.make_branch_and_memory_tree(
 
116
            relpath, format=self.branch_format_to._matchingbzrdir)
119
117
 
120
118
    def make_to_branch_and_tree(self, relpath):
121
119
        """Create a branch on the default transport and a working tree for it."""
122
 
        b = self.make_to_branch(relpath)
123
 
        return b.bzrdir.create_workingtree()
 
120
        self.assertEquals(
 
121
            self.branch_format_to._matchingbzrdir.get_branch_format(),
 
122
            self.branch_format_to)
 
123
        return self.make_branch_and_tree(relpath,
 
124
            format=self.branch_format_to._matchingbzrdir)
 
125
 
 
126
    def _sprout(self, origdir, to_url, format):
 
127
        if format.supports_workingtrees:
 
128
            newbranch = self.make_branch(to_url, format=format)
 
129
        else:
 
130
            newbranch = self.make_branch(to_url+".branch", format=format)
 
131
        origbranch = origdir.open_branch()
 
132
        newbranch.repository.fetch(origbranch.repository)
 
133
        origbranch.copy_content_into(newbranch)
 
134
        if format.supports_workingtrees:
 
135
            wt = newbranch.bzrdir.create_workingtree()
 
136
        else:
 
137
            wt = newbranch.create_checkout(to_url, lightweight=True)
 
138
        return wt
124
139
 
125
140
    def sprout_to(self, origdir, to_url):
126
141
        """Sprout a bzrdir, using to_format for the new branch."""
127
 
        newbranch = self.make_to_branch(to_url)
128
 
        origbranch = origdir.open_branch()
129
 
        newbranch.repository.fetch(origbranch.repository)
130
 
        origbranch.copy_content_into(newbranch)
131
 
        newbranch.bzrdir.create_workingtree()
132
 
        return newbranch.bzrdir
 
142
        wt = self._sprout(origdir, to_url, self.branch_format_to._matchingbzrdir)
 
143
        self.assertEquals(wt.branch._format, self.branch_format_to)
 
144
        return wt.bzrdir
133
145
 
134
146
    def sprout_from(self, origdir, to_url):
135
147
        """Sprout a bzrdir, using from_format for the new bzrdir."""
136
 
        newbranch = self.make_from_branch(to_url)
137
 
        origbranch = origdir.open_branch()
138
 
        newbranch.repository.fetch(origbranch.repository)
139
 
        origbranch.copy_content_into(newbranch)
140
 
        newbranch.bzrdir.create_workingtree()
141
 
        return newbranch.bzrdir
 
148
        wt = self._sprout(origdir, to_url,
 
149
            self.branch_format_from._matchingbzrdir)
 
150
        self.assertEquals(wt.branch._format, self.branch_format_from)
 
151
        return wt.bzrdir
142
152
 
143
153
 
144
154
class StubWithFormat(object):
171
181
 
172
182
def load_tests(standard_tests, module, loader):
173
183
    submod_tests = loader.loadTestsFromModuleNames([
 
184
        'bzrlib.tests.per_interbranch.test_fetch',
174
185
        'bzrlib.tests.per_interbranch.test_get',
175
186
        'bzrlib.tests.per_interbranch.test_copy_content_into',
176
187
        'bzrlib.tests.per_interbranch.test_pull',
177
188
        'bzrlib.tests.per_interbranch.test_push',
178
 
        'bzrlib.tests.per_interbranch.test_update_revisions',
179
189
        ])
180
190
    scenarios = make_scenarios(default_test_list())
181
191
    return multiply_tests(submod_tests, scenarios, standard_tests)