~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_switch.py

  • Committer: Aaron Bentley
  • Date: 2007-11-23 15:13:59 UTC
  • Revision ID: abentley@panoramicfeedback.com-20071123151359-yrjc6ta2fkbtu9ht
Remove switch (now in bzr itself)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
 
3
 
from bzrlib import branch, errors, tests
4
 
 
5
 
from bzrlib.plugins.bzrtools.switch import switch
6
 
 
7
 
class TestSwitch(tests.TestCaseWithTransport):
8
 
 
9
 
    def test_switch_moved(self):
10
 
        tree = self.make_branch_and_tree('branch-1')
11
 
        self.build_tree(['branch-1/file-1'])
12
 
        tree.add('file-1')
13
 
        tree.commit('rev1')
14
 
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
15
 
        self.build_tree(['branch-1/file-2'])
16
 
        tree.add('file-2')
17
 
        tree.remove('file-1')
18
 
        tree.commit('rev2')
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')
27
 
 
28
 
    def test_switch_old(self):
29
 
        tree = self.make_branch_and_tree('branch-1')
30
 
        self.build_tree(['branch-1/file-1'])
31
 
        tree.add('file-1')
32
 
        tree.commit('rev1')
33
 
        to_branch = tree.bzrdir.sprout('branch-2').open_branch()
34
 
        self.build_tree(['branch-1/file-2'])
35
 
        tree.add('file-2')
36
 
        tree.remove('file-1')
37
 
        tree.commit('rev2')
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')
47
 
 
48
 
    def test_switch_heavy_checkout(self):
49
 
        tree = self.make_branch_and_tree('branch-1')
50
 
        self.build_tree(['branch-1/file-1'])
51
 
        tree.add('file-1')
52
 
        tree.commit('rev1')
53
 
        tree.branch.create_checkout('checkout-1', lightweight=False)
54
 
        branch2 = self.make_branch('branch-2')
55
 
        err = self.assertRaises(errors.BzrCommandError,
56
 
                                switch, tree.bzrdir, branch2)
57
 
        self.assertContainsRe(str(err),
58
 
            "The switch command can only be used on a light checkout")