123
128
self.assertIs(None, self.git_branch.get_parent())
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)
128
134
def test_get_physical_lock_status(self):
129
135
self.assertFalse(self.git_branch.get_physical_lock_status())
154
160
return "d", gitsha
162
def make_tworev_branch(self):
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")
172
return "d", (marks[mark1], marks[mark2])
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())
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)
204
self.assertEquals(revid2, newbranch.last_revision())
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)
213
# This is basically "assertNotRaises"
215
self.assertEquals(revid2, newbranch.last_revision())
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())
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())
239
class ForeignTestsBranchFactory(object):
241
def make_empty_branch(self, transport):
242
return LocalGitBzrDirFormat().initialize_on_transport(transport).open_branch()
244
make_branch = make_empty_branch