~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from bzrlib import (
29
29
    branchbuilder,
 
30
    memorytree,
30
31
    )
31
32
from bzrlib.branch import (
32
33
                           GenericInterBranch,
33
34
                           InterBranch,
34
35
                           )
 
36
from bzrlib.bzrdir import (
 
37
    BzrDirFormat,
 
38
    BzrDirMetaFormat1,
 
39
    )
35
40
from bzrlib.tests import (
36
41
    TestCaseWithTransport,
37
42
    multiply_tests,
76
81
class TestCaseWithInterBranch(TestCaseWithTransport):
77
82
 
78
83
    def make_from_branch(self, relpath):
79
 
        return self.make_branch(relpath, format=self.branch_format_from._matchingbzrdir)
 
84
        repo = self.make_repository(relpath, format=self.branch_format_from._matchingbzrdir)
 
85
        return self.branch_format_from.initialize(repo.bzrdir)
80
86
 
81
87
    def make_from_branch_and_memory_tree(self, relpath):
82
88
        """Create a branch on the default transport and a MemoryTree for it."""
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)
 
89
        b = self.make_from_branch(relpath)
 
90
        return memorytree.MemoryTree.create_on_branch(b)
88
91
 
89
92
    def make_from_branch_and_tree(self, relpath):
90
93
        """Create a branch on the default transport and a working tree for it."""
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)
 
94
        b = self.make_from_branch(relpath)
 
95
        return b.bzrdir.create_workingtree()
96
96
 
97
97
    def make_from_branch_builder(self, relpath):
98
 
        self.assertEquals(
99
 
            self.branch_format_from._matchingbzrdir.get_branch_format(),
100
 
            self.branch_format_from)
 
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
101
103
        return branchbuilder.BranchBuilder(self.get_transport(relpath),
102
 
            format=self.branch_format_from._matchingbzrdir)
 
104
            format=format)
103
105
 
104
106
    def make_to_branch(self, relpath):
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)
 
107
        repo = self.make_repository(relpath, format=self.branch_format_to._matchingbzrdir)
 
108
        return self.branch_format_to.initialize(repo.bzrdir)
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
 
        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)
 
112
        b = self.make_to_branch(relpath)
 
113
        return memorytree.MemoryTree.create_on_branch(b)
117
114
 
118
115
    def make_to_branch_and_tree(self, relpath):
119
116
        """Create a branch on the default transport and a working tree for it."""
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
 
117
        b = self.make_to_branch(relpath)
 
118
        return b.bzrdir.create_workingtree()
139
119
 
140
120
    def sprout_to(self, origdir, to_url):
141
121
        """Sprout a bzrdir, using to_format for the new branch."""
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
 
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
145
128
 
146
129
    def sprout_from(self, origdir, to_url):
147
130
        """Sprout a bzrdir, using from_format for the new 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
 
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
152
137
 
153
138
 
154
139
class StubWithFormat(object):