~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_switch.py

  • Committer: Aaron Bentley
  • Date: 2007-08-23 03:04:42 UTC
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: aaron.bentley@utoronto.ca-20070823030442-3runylf3uhwz1jmi
bzr switch works when the source branch is renamed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
 
 
3
from bzrlib import branch, 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')