/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

Escape slashes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    )
29
29
 
30
30
import os
 
31
import urllib
31
32
 
32
33
from bzrlib import (
33
34
    errors,
34
35
    revision,
 
36
    urlutils,
35
37
    )
36
38
from bzrlib.branch import (
37
39
    Branch,
45
47
    )
46
48
 
47
49
from bzrlib.plugins.git import (
48
 
    LocalGitControlDirFormat,
49
50
    branch,
50
51
    tests,
51
52
    )
 
53
from bzrlib.plugins.git.dir import (
 
54
    LocalGitControlDirFormat,
 
55
    )
52
56
from bzrlib.plugins.git.mapping import (
53
57
    default_mapping,
54
58
    )
56
60
 
57
61
class TestGitBranch(tests.TestCaseInTempDir):
58
62
 
 
63
    def test_open_by_ref(self):
 
64
        GitRepo.init('.')
 
65
        d = BzrDir.open("%s,ref=%s" % (
 
66
            urlutils.local_path_to_url(self.test_dir),
 
67
            urllib.quote("refs/remotes/origin/unstable", safe='')
 
68
            ))
 
69
        b = d.create_branch()
 
70
        self.assertEquals(b.ref, "refs/remotes/origin/unstable")
 
71
 
59
72
    def test_open_existing(self):
60
73
        GitRepo.init('.')
61
74
        d = BzrDir.open('.')
66
79
        GitRepo.init('.')
67
80
        d = BzrDir.open('.')
68
81
        thebranch = d.create_branch()
69
 
        self.assertEquals("<LocalGitBranch('file://%s/', 'HEAD')>" % self.test_dir, repr(thebranch))
 
82
        self.assertEquals(
 
83
            "<LocalGitBranch('%s/', u'master')>" % (
 
84
                urlutils.local_path_to_url(self.test_dir),),
 
85
            repr(thebranch))
70
86
 
71
87
    def test_last_revision_is_null(self):
72
88
        GitRepo.init('.')
171
187
        mark = bb.commit("Somebody <somebody@someorg.org>", "mymsg")
172
188
        gitsha = bb.finish()[mark]
173
189
        os.chdir("..")
174
 
        return "d", gitsha
 
190
        return os.path.abspath("d"), gitsha
175
191
 
176
192
    def make_tworev_branch(self):
177
193
        os.mkdir("d")
194
210
        path, gitsha = self.make_onerev_branch()
195
211
        oldrepo = Repository.open(path)
196
212
        revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha)
 
213
        self.assertEquals(gitsha, oldrepo._git.get_refs()["refs/heads/master"])
197
214
        newbranch = self.clone_git_branch(path, "f")
198
215
        self.assertEquals([revid], newbranch.repository.all_revision_ids())
199
216
 
236
253
        inter_branch.pull(stop_revision=revid1)
237
254
        self.assertEquals(revid1, newbranch.last_revision())
238
255
 
239
 
    def test_interbranch_limited_pull(self):
 
256
    def test_interbranch_pull_with_tags(self):
240
257
        path, (gitsha1, gitsha2) = self.make_tworev_branch()
 
258
        gitrepo = GitRepo(path)
 
259
        gitrepo.refs["refs/tags/sometag"] = gitsha2
241
260
        oldrepo = Repository.open(path)
242
261
        revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1)
243
262
        revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2)
244
263
        newbranch = self.make_branch('g')
245
 
        inter_branch = InterBranch.get(Branch.open(path), newbranch)
246
 
        inter_branch.pull(limit=1)
 
264
        source_branch = Branch.open(path)
 
265
        source_branch.get_config().set_user_option("branch.fetch_tags", True)
 
266
        inter_branch = InterBranch.get(source_branch, newbranch)
 
267
        inter_branch.pull(stop_revision=revid1)
247
268
        self.assertEquals(revid1, newbranch.last_revision())
248
 
        inter_branch.pull(limit=1)
249
 
        self.assertEquals(revid2, newbranch.last_revision())
 
269
        self.assertTrue(newbranch.repository.has_revision(revid2))
250
270
 
251
271
 
252
272
class ForeignTestsBranchFactory(object):
256
276
        return d.create_branch()
257
277
 
258
278
    make_branch = make_empty_branch
259
 
 
260
 
 
261