47
49
from bzrlib.plugins.git import (
48
LocalGitControlDirFormat,
53
from bzrlib.plugins.git.dir import (
54
LocalGitControlDirFormat,
52
56
from bzrlib.plugins.git.mapping import (
57
61
class TestGitBranch(tests.TestCaseInTempDir):
63
def test_open_by_ref(self):
65
d = BzrDir.open("%s,ref=%s" % (
66
urlutils.local_path_to_url(self.test_dir),
67
urllib.quote("refs/remotes/origin/unstable", safe='')
70
self.assertEquals(b.ref, "refs/remotes/origin/unstable")
59
72
def test_open_existing(self):
61
74
d = BzrDir.open('.')
67
80
d = BzrDir.open('.')
68
81
thebranch = d.create_branch()
69
self.assertEquals("<LocalGitBranch('file://%s/', 'HEAD')>" % self.test_dir, repr(thebranch))
83
"<LocalGitBranch('%s/', u'master')>" % (
84
urlutils.local_path_to_url(self.test_dir),),
71
87
def test_last_revision_is_null(self):
171
187
mark = bb.commit("Somebody <somebody@someorg.org>", "mymsg")
172
188
gitsha = bb.finish()[mark]
190
return os.path.abspath("d"), gitsha
176
192
def make_tworev_branch(self):
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())
236
253
inter_branch.pull(stop_revision=revid1)
237
254
self.assertEquals(revid1, newbranch.last_revision())
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))
252
272
class ForeignTestsBranchFactory(object):