3
from bzrlib import branch, tests
5
from bzrlib.plugins.bzrtools.switch import switch
7
class TestSwitch(tests.TestCaseWithTransport):
9
def test_switch_moved(self):
10
tree = self.make_branch_and_tree('branch-1')
11
self.build_tree(['branch-1/file-1'])
14
checkout = tree.branch.create_checkout('checkout', lightweight=True)
15
self.build_tree(['branch-1/file-2'])
19
os.rename('branch-1', 'branch-2')
20
to_branch = branch.Branch.open('branch-2')
21
self.build_tree(['checkout/file-3'])
22
checkout.add('file-3')
23
switch(checkout.bzrdir, to_branch)
24
self.failIfExists('checkout/file-1')
25
self.failUnlessExists('checkout/file-2')
26
self.failUnlessExists('checkout/file-3')
28
def test_switch_old(self):
29
tree = self.make_branch_and_tree('branch-1')
30
self.build_tree(['branch-1/file-1'])
33
to_branch = tree.bzrdir.sprout('branch-2').open_branch()
34
self.build_tree(['branch-1/file-2'])
38
checkout = tree.branch.create_checkout('checkout', lightweight=True)
39
self.build_tree(['checkout/file-3'])
40
checkout.add('file-3')
41
self.failIfExists('checkout/file-1')
42
self.failUnlessExists('checkout/file-2')
43
switch(checkout.bzrdir, to_branch)
44
self.failUnlessExists('checkout/file-1')
45
self.failIfExists('checkout/file-2')
46
self.failUnlessExists('checkout/file-3')