/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_branch.py

Implement to_files() for git merge directives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import os
27
27
 
28
28
from bzrlib import (
 
29
    errors,
29
30
    revision,
30
31
    )
31
32
from bzrlib.branch import (
32
33
    Branch,
 
34
    InterBranch,
33
35
    )
34
36
from bzrlib.bzrdir import (
35
37
    BzrDir,
39
41
    )
40
42
 
41
43
from bzrlib.plugins.git import (
 
44
    LocalGitBzrDirFormat,
42
45
    branch,
43
46
    tests,
44
47
    )
45
 
from bzrlib.plugins.git.mapping import default_mapping
 
48
from bzrlib.plugins.git.mapping import (
 
49
    default_mapping,
 
50
    )
46
51
 
47
52
 
48
53
class TestGitBranch(tests.TestCaseInTempDir):
123
128
        self.assertIs(None, self.git_branch.get_parent())
124
129
 
125
130
    def test_get_stacked_on_url(self):
126
 
        self.assertIs(None, self.git_branch.get_stacked_on_url())
 
131
        self.assertRaises(errors.UnstackableBranchFormat, 
 
132
            self.git_branch.get_stacked_on_url)
127
133
 
128
134
    def test_get_physical_lock_status(self):
129
135
        self.assertFalse(self.git_branch.get_physical_lock_status())
153
159
        os.chdir("..")
154
160
        return "d", gitsha
155
161
 
 
162
    def make_tworev_branch(self):
 
163
        os.mkdir("d")
 
164
        os.chdir("d")
 
165
        GitRepo.init('.')
 
166
        bb = tests.GitBranchBuilder()
 
167
        bb.set_file("foobar", "foo\nbar\n", False)
 
168
        mark1 = bb.commit("Somebody <somebody@someorg.org>", "mymsg")
 
169
        mark2 = bb.commit("Somebody <somebody@someorg.org>", "mymsg")
 
170
        marks = bb.finish()
 
171
        os.chdir("..")
 
172
        return "d", (marks[mark1], marks[mark2])
 
173
 
156
174
    def clone_git_branch(self, from_url, to_url):
157
175
        from_dir = BzrDir.open(from_url)
158
176
        to_dir = from_dir.sprout(to_url)
175
193
        newbranch = self.clone_git_branch(path, "f")
176
194
        self.assertEquals({"lala": revid}, newbranch.tags.get_tag_dict())
177
195
        self.assertEquals([revid], newbranch.repository.all_revision_ids())
 
196
 
 
197
    def test_interbranch_pull(self):
 
198
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
 
199
        oldrepo = Repository.open(path)
 
200
        revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2)
 
201
        newbranch = self.make_branch('g')
 
202
        inter_branch = InterBranch.get(Branch.open(path), newbranch)
 
203
        inter_branch.pull()
 
204
        self.assertEquals(revid2, newbranch.last_revision())
 
205
 
 
206
    def test_interbranch_pull_noop(self):
 
207
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
 
208
        oldrepo = Repository.open(path)
 
209
        revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2)
 
210
        newbranch = self.make_branch('g')
 
211
        inter_branch = InterBranch.get(Branch.open(path), newbranch)
 
212
        inter_branch.pull()
 
213
        # This is basically "assertNotRaises"
 
214
        inter_branch.pull()
 
215
        self.assertEquals(revid2, newbranch.last_revision())
 
216
 
 
217
    def test_interbranch_pull_stop_revision(self):
 
218
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
 
219
        oldrepo = Repository.open(path)
 
220
        revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1)
 
221
        newbranch = self.make_branch('g')
 
222
        inter_branch = InterBranch.get(Branch.open(path), newbranch)
 
223
        inter_branch.pull(stop_revision=revid1)
 
224
        self.assertEquals(revid1, newbranch.last_revision())
 
225
 
 
226
    def test_interbranch_limited_pull(self):
 
227
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
 
228
        oldrepo = Repository.open(path)
 
229
        revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1)
 
230
        revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2)
 
231
        newbranch = self.make_branch('g')
 
232
        inter_branch = InterBranch.get(Branch.open(path), newbranch)
 
233
        inter_branch.pull(limit=1)
 
234
        self.assertEquals(revid1, newbranch.last_revision())
 
235
        inter_branch.pull(limit=1)
 
236
        self.assertEquals(revid2, newbranch.last_revision())
 
237
 
 
238
 
 
239
class ForeignTestsBranchFactory(object):
 
240
 
 
241
    def make_empty_branch(self, transport):
 
242
        return LocalGitBzrDirFormat().initialize_on_transport(transport).open_branch()
 
243
 
 
244
    make_branch = make_empty_branch