41
41
from bzrlib.osutils import getcwd
42
42
import bzrlib.revision
43
from bzrlib.symbol_versioning import deprecated_in
43
44
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
44
45
from bzrlib.tests.branch_implementations import TestCaseWithBranch
45
46
from bzrlib.tests.http_server import HttpServer
48
49
from bzrlib.transport.memory import MemoryServer
49
50
from bzrlib.upgrade import upgrade
50
51
from bzrlib.workingtree import WorkingTree
51
from bzrlib.symbol_versioning import (
56
54
class TestBranch(TestCaseWithBranch):
307
305
self.assertEqual(repo.get_signature_text('A'),
308
306
d2.open_repository().get_signature_text('A'))
308
def test_missing_revisions(self):
309
t1 = self.make_branch_and_tree('b1')
310
rev1 = t1.commit('one')
311
t2 = t1.bzrdir.sprout('b2').open_workingtree()
312
rev2 = t1.commit('two')
313
rev3 = t1.commit('three')
315
self.assertEqual([rev2, rev3],
316
self.applyDeprecated(deprecated_in((1, 6, 0)),
317
t2.branch.missing_revisions, t1.branch))
320
self.applyDeprecated(deprecated_in((1, 6, 0)),
321
t2.branch.missing_revisions, t1.branch, stop_revision=1))
322
self.assertEqual([rev2],
323
self.applyDeprecated(deprecated_in((1, 6, 0)),
324
t2.branch.missing_revisions, t1.branch, stop_revision=2))
325
self.assertEqual([rev2, rev3],
326
self.applyDeprecated(deprecated_in((1, 6, 0)),
327
t2.branch.missing_revisions, t1.branch, stop_revision=3))
329
self.assertRaises(errors.NoSuchRevision,
330
self.applyDeprecated, deprecated_in((1, 6, 0)),
331
t2.branch.missing_revisions, t1.branch, stop_revision=4)
333
rev4 = t2.commit('four')
334
self.assertRaises(errors.DivergedBranches,
335
self.applyDeprecated, deprecated_in((1, 6, 0)),
336
t2.branch.missing_revisions, t1.branch)
310
338
def test_nicks(self):
311
339
"""Test explicit and implicit branch nicknames.
326
354
# Set the branch nick explicitly. This will ensure there's a branch
327
355
# config file in the branch.
328
356
branch.nick = "Aaron's branch"
329
branch.nick = "Aaron's branch"
330
357
if not isinstance(branch, remote.RemoteBranch):
331
controlfilename = branch.control_files.controlfilename
332
self.failUnless(t.has(t.relpath(controlfilename("branch.conf"))))
358
self.failUnless(branch._transport.has("branch.conf"))
333
359
# Because the nick has been set explicitly, the nick is now always
334
360
# "Aaron's branch", regardless of directory name.
335
361
self.assertEqual(branch.nick, "Aaron's branch")