~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_interbranch/__init__.py

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

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
35
from bzrlib.tests import (
41
36
    TestCaseWithTransport,
42
37
    multiply_tests,
81
76
class TestCaseWithInterBranch(TestCaseWithTransport):
82
77
 
83
78
    def make_from_branch(self, relpath):
84
 
        repo = self.make_repository(relpath, format=self.branch_format_from._matchingbzrdir)
85
 
        return self.branch_format_from.initialize(repo.bzrdir)
 
79
        return self.make_branch(relpath, format=self.branch_format_from._matchingbzrdir)
86
80
 
87
81
    def make_from_branch_and_memory_tree(self, relpath):
88
82
        """Create a branch on the default transport and a MemoryTree for it."""
89
 
        b = self.make_from_branch(relpath)
90
 
        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)
91
88
 
92
89
    def make_from_branch_and_tree(self, relpath):
93
90
        """Create a branch on the default transport and a working tree for it."""
94
 
        b = self.make_from_branch(relpath)
95
 
        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)
96
96
 
97
97
    def make_from_branch_builder(self, relpath):
98
 
        default_format = BzrDirFormat.get_default_format()
99
 
        format = BzrDirMetaFormat1()
100
 
        format.set_branch_format(self.branch_format_from)
101
 
        format.repository_format = default_format.repository_format
102
 
        format.workingtree_format = default_format.workingtree_format
 
98
        self.assertEquals(
 
99
            self.branch_format_from._matchingbzrdir.get_branch_format(),
 
100
            self.branch_format_from)
103
101
        return branchbuilder.BranchBuilder(self.get_transport(relpath),
104
 
            format=format)
 
102
            format=self.branch_format_from._matchingbzrdir)
105
103
 
106
104
    def make_to_branch(self, relpath):
107
 
        repo = self.make_repository(relpath, format=self.branch_format_to._matchingbzrdir)
108
 
        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)
109
109
 
110
110
    def make_to_branch_and_memory_tree(self, relpath):
111
111
        """Create a branch on the default transport and a MemoryTree for it."""
112
 
        b = self.make_to_branch(relpath)
113
 
        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)
114
117
 
115
118
    def make_to_branch_and_tree(self, relpath):
116
119
        """Create a branch on the default transport and a working tree for it."""
117
 
        b = self.make_to_branch(relpath)
118
 
        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
119
139
 
120
140
    def sprout_to(self, origdir, to_url):
121
141
        """Sprout a bzrdir, using to_format for the new branch."""
122
 
        newbranch = self.make_to_branch(to_url)
123
 
        origbranch = origdir.open_branch()
124
 
        newbranch.repository.fetch(origbranch.repository)
125
 
        origbranch.copy_content_into(newbranch)
126
 
        newbranch.bzrdir.create_workingtree()
127
 
        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
128
145
 
129
146
    def sprout_from(self, origdir, to_url):
130
147
        """Sprout a bzrdir, using from_format for the new bzrdir."""
131
 
        newbranch = self.make_from_branch(to_url)
132
 
        origbranch = origdir.open_branch()
133
 
        newbranch.repository.fetch(origbranch.repository)
134
 
        origbranch.copy_content_into(newbranch)
135
 
        newbranch.bzrdir.create_workingtree()
136
 
        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
137
152
 
138
153
 
139
154
class StubWithFormat(object):