131
133
target = b.repository.generate_revision_id(1, "trunk", b.repository.get_mapping())
132
134
b.tags.set_tag(u"mytag", b.repository.generate_revision_id(1, "trunk", b.repository.get_mapping()))
134
self.assertEquals(subvertpy.NODE_DIR,
136
self.assertEquals(subvertpy.NODE_DIR,
135
137
b.repository.transport.check_path("tags/mytag", 3))
136
138
self.assertEquals(3, b.repository.get_latest_revnum())
168
170
newtagrevid = b.repository.generate_revision_id(2, "trunk", b.repository.get_mapping())
169
171
b.tags.set_tag(u"mytag", newtagrevid)
171
self.assertEquals(subvertpy.NODE_DIR,
173
self.assertEquals(subvertpy.NODE_DIR,
172
174
b.repository.transport.check_path("tags/mytag", 4))
173
175
self.assertEquals(4, b.repository.get_latest_revnum())
174
176
b = Branch.open(repos_url + "/trunk")
175
177
log = self.client_log(repos_url, 4, 0)
176
178
self.assertEquals(log[0][0], None)
177
self.assertEquals(log[1][0], {'/tags': ('A', None, -1),
179
self.assertEquals(log[1][0], {'/tags': ('A', None, -1),
178
180
'/trunk': ('A', None, -1)})
179
181
self.assertEquals(log[2][0], {'/trunk/bla': ('A', None, -1)})
180
182
self.assertEquals(log[3][0], {'/tags/mytag': ('A', '/trunk', 1)})
212
214
b = Branch.open(repos_url + "/trunk")
213
215
b.tags.set_tag(u"mytag",
214
b.repository.generate_revision_id(1, "trunk", b.repository.get_mapping()))
216
b.repository.generate_revision_id(1, "trunk",
217
b.repository.get_mapping()))
216
self.assertEquals(subvertpy.NODE_DIR,
219
self.assertEquals(subvertpy.NODE_DIR,
217
220
b.repository.transport.check_path("tags", 3))
219
self.assertEquals(subvertpy.NODE_DIR,
222
self.assertEquals(subvertpy.NODE_DIR,
220
223
b.repository.transport.check_path("tags/mytag", 4))
221
224
self.assertEquals(4, b.repository.get_latest_revnum())
231
234
b = Branch.open(repos_url + "/trunk/gui")
232
235
self.assertRaises(TagsNotSupported,
233
b.tags.set_tag, u"mytag",
234
b.repository.generate_revision_id(1, "trunk/gui", b.repository.get_mapping()))
236
b.tags.set_tag, u"mytag",
237
b.repository.generate_revision_id(1, "trunk/gui",
238
b.repository.get_mapping()))
236
240
def test_tag_lookup(self):
237
241
repos_url = self.make_repository("a")
239
243
dc = self.get_commit_editor(repos_url)
240
244
tags = dc.add_dir("tags")
241
245
tags.add_dir("tags/foo")
245
249
b = Branch.open(repos_url + "/trunk")
246
250
self.assertEquals("", b.project)
247
self.assertEquals(b.repository.generate_revision_id(1, "tags/foo", b.repository.get_mapping()), b.tags.lookup_tag("foo"))
252
b.repository.generate_revision_id(1, "tags/foo",
253
b.repository.get_mapping()),
254
b.tags.lookup_tag("foo"))
249
256
def test_tag_lookup_nonexistant(self):
250
257
repos_url = self.make_repository("a")
305
312
self.assertEquals(result.source_branch, otherbranch)
306
313
self.assertEquals(result.target_branch, branch)
315
def make_tworev_branch(self):
316
repos_url = self.make_repository("a")
318
dc = self.get_commit_editor(repos_url)
322
b = Branch.open(repos_url)
323
mapping = b.repository.get_mapping()
324
uuid = b.repository.uuid
325
revid1 = mapping.revision_id_foreign_to_bzr((uuid, '', 0))
326
revid2 = mapping.revision_id_foreign_to_bzr((uuid, '', 1))
327
return b, (revid1, revid2)
329
def make_branch(self, relpath):
330
# The inherited make_branch is broken, thanks to the make_repository
332
bzrdir = self.make_bzrdir(relpath)
333
bzrdir._find_or_create_repository(True)
334
return bzrdir.create_branch()
336
def test_interbranch_pull(self):
337
svn_branch, (revid1, revid2) = self.make_tworev_branch()
338
new_branch = self.make_branch("b")
339
inter_branch = InterBranch.get(svn_branch, new_branch)
341
self.assertEquals(revid2, new_branch.last_revision())
343
def test_interbranch_pull_noop(self):
344
svn_branch, (revid1, revid2) = self.make_tworev_branch()
345
new_branch = self.make_branch("b")
346
inter_branch = InterBranch.get(svn_branch, new_branch)
348
# This is basically "assertNotRaises"
350
self.assertEquals(revid2, new_branch.last_revision())
352
def test_interbranch_pull_stop_revision(self):
353
svn_branch, (revid1, revid2) = self.make_tworev_branch()
354
new_branch = self.make_branch("b")
355
inter_branch = InterBranch.get(svn_branch, new_branch)
356
inter_branch.pull(stop_revision=revid1)
357
self.assertEquals(revid1, new_branch.last_revision())
359
def test_interbranch_limited_pull(self):
360
svn_branch, (revid1, revid2) = self.make_tworev_branch()
361
new_branch = self.make_branch("b")
362
inter_branch = InterBranch.get(svn_branch, new_branch)
363
inter_branch.pull(limit=1)
364
self.assertEquals(revid1, new_branch.last_revision())
365
inter_branch.pull(limit=1)
366
self.assertEquals(revid2, new_branch.last_revision())
368
def test_interbranch_limited_overwrite(self):
369
svn_branch, (revid1, revid2) = self.make_tworev_branch()
370
new_branch = self.make_branch("b")
371
inter_branch = InterBranch.get(svn_branch, new_branch)
372
inter_branch.pull(limit=2)
373
self.assertEquals(revid2, new_branch.last_revision())
374
inter_branch.pull(limit=1, stop_revision=revid1)
375
self.assertEquals(revid2, new_branch.last_revision())
376
inter_branch.pull(limit=1, overwrite=True, stop_revision=revid1)
377
self.assertEquals(revid1, new_branch.last_revision())
308
379
def test_get_branch_path_subdir(self):
309
380
repos_url = self.make_repository("a")
315
386
branch = Branch.open(repos_url+"/trunk")
316
387
self.assertEqual("trunk", branch.get_branch_path())
389
def test_tag_added_later(self):
390
repos_url = self.make_repository("a")
392
dc = self.get_commit_editor(repos_url)
396
olddir = BzrDir.open(repos_url+"/trunk")
397
oldbranch = olddir.open_branch()
398
newdir = olddir.sprout("mycopy")
399
newbranch = newdir.open_branch()
400
self.assertEquals({}, newbranch.tags.get_tag_dict())
402
dc = self.get_commit_editor(repos_url)
403
tags = dc.add_dir("tags")
404
new_tag = tags.add_dir("tags/newtag", "trunk")
407
self.assertEquals(1, oldbranch.get_revnum())
408
newbranch.pull(oldbranch, stop_revision=oldbranch.last_revision())
410
self.assertEquals(["newtag"], newbranch.tags.get_tag_dict().keys())
318
412
def test_open_nonexistant(self):
319
413
repos_url = self.make_repository("a")
320
414
self.assertRaises(NotBranchError, Branch.open, repos_url + "/trunk")
331
425
def test_lookup_revision_id_unknown(self):
332
426
repos_url = self.make_repository("a")
333
427
branch = Branch.open(repos_url)
334
self.assertRaises(NoSuchRevision,
428
self.assertRaises(NoSuchRevision,
335
429
lambda: branch.lookup_bzr_revision_id("bla"))
337
431
def test_lookup_revision_id(self):
338
432
repos_url = self.make_repository("a")
339
433
branch = Branch.open(repos_url)
341
435
branch.lookup_bzr_revision_id(branch.last_revision()))
343
437
def test_set_parent(self):
355
449
dc = self.get_commit_editor(repos_url)
356
450
dc.add_file("foo").modify()
359
453
bzrdir = BzrDir.open(repos_url)
360
454
branch = bzrdir.open_branch()
361
455
repos = bzrdir.find_repository()
363
457
mapping = repos.get_mapping()
365
self.assertEqual(repos.generate_revision_id(1, "", mapping),
459
self.assertEqual(repos.generate_revision_id(1, "", mapping),
366
460
branch.last_revision())
368
462
dc = self.get_commit_editor(repos_url)
980
1074
self.assertRaises(NotImplementedError, self.format.initialize, None)
982
1076
def test_get_format_string(self):
983
self.assertEqual("Subversion Smart Server",
1077
self.assertEqual("Subversion Smart Server",
984
1078
self.format.get_format_string())
986
1080
def test_get_format_description(self):
987
self.assertEqual("Subversion Smart Server",
1081
self.assertEqual("Subversion Smart Server",
988
1082
self.format.get_format_description())
991
1085
class ForeignTestsBranchFactory(object):
993
1087
def make_empty_branch(self, transport):
996
1090
def make_branch(self, transport):
997
1091
subvertpy.repos.create(transport.local_abspath("."))