~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_switch.py

  • Committer: Ian Clatworthy
  • Date: 2007-12-05 12:54:51 UTC
  • mto: (3092.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3093.
  • Revision ID: ian.clatworthy@internode.on.net-20071205125451-oe6p3gekbfhyxuzt
Add test for local commits handling

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
    def setUp(self):
100
100
        super(TestSwitchHeavyweight, self).setUp()
101
101
        self.lightweight = False
 
102
 
 
103
    def test_switch_with_local_commits(self):
 
104
        """Test switch complains about local commits unless --force given."""
 
105
        tree = self._setup_tree()
 
106
        to_branch = tree.bzrdir.sprout('branch-2').open_branch()
 
107
        self.build_tree(['branch-1/file-2'])
 
108
        tree.add('file-2')
 
109
        tree.remove('file-1')
 
110
        tree.commit('rev2')
 
111
        checkout = tree.branch.create_checkout('checkout')
 
112
        self.build_tree(['checkout/file-3'])
 
113
        checkout.add('file-3')
 
114
        checkout.commit(message='local only commit', local=True)
 
115
        self.build_tree(['checkout/file-4'])
 
116
        # Check the error reporting is as expected
 
117
        err = self.assertRaises(errors.BzrCommandError,
 
118
            switch.switch, checkout.bzrdir, to_branch)
 
119
        self.assertContainsRe(str(err),
 
120
            'Cannot switch as local commits found in the checkout.')
 
121
        # Check all is ok when force is given
 
122
        self.failIfExists('checkout/file-1')
 
123
        self.failUnlessExists('checkout/file-2')
 
124
        switch.switch(checkout.bzrdir, to_branch, force=True)
 
125
        self.failUnlessExists('checkout/file-1')
 
126
        self.failIfExists('checkout/file-2')
 
127
        self.failIfExists('checkout/file-3')
 
128
        self.failUnlessExists('checkout/file-4')
 
129
        # Check that the checkout is a true mirror of the bound branch
 
130
        missing_in_checkout = checkout.branch.missing_revisions(to_branch)
 
131
        self.assertEqual([], missing_in_checkout)
 
132
        missing_in_remote = to_branch.missing_revisions(checkout.branch)
 
133
        self.assertEqual([], missing_in_remote)