~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_switch.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-24 13:14:06 UTC
  • mto: (6445.4.5 nested-trees-spec)
  • mto: This revision was merged to the branch mainline in revision 6518.
  • Revision ID: jelmer@samba.org-20120124131406-wedftkorbpv37bm0
Import nested tree doc from devnotes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
25
25
    merge as _mod_merge,
26
26
    switch,
27
27
    tests,
28
 
)
 
28
    )
29
29
 
30
30
 
31
31
class TestSwitch(tests.TestCaseWithTransport):
53
53
            lightweight=self.lightweight)
54
54
        self.build_tree(['checkout/file-3'])
55
55
        checkout.add('file-3')
56
 
        self.failIfExists('checkout/file-1')
57
 
        self.failUnlessExists('checkout/file-2')
 
56
        self.assertPathDoesNotExist('checkout/file-1')
 
57
        self.assertPathExists('checkout/file-2')
58
58
        switch.switch(checkout.bzrdir, to_branch)
59
 
        self.failUnlessExists('checkout/file-1')
60
 
        self.failIfExists('checkout/file-2')
61
 
        self.failUnlessExists('checkout/file-3')
 
59
        self.assertPathExists('checkout/file-1')
 
60
        self.assertPathDoesNotExist('checkout/file-2')
 
61
        self.assertPathExists('checkout/file-3')
62
62
 
63
63
    def test_switch_after_branch_moved(self):
64
64
        """Test switch after the branch is moved."""
84
84
                'Unable to connect to current master branch .*'
85
85
                'To switch anyway, use --force.')
86
86
        switch.switch(checkout.bzrdir, to_branch, force=True)
87
 
        self.failIfExists('checkout/file-1')
88
 
        self.failUnlessExists('checkout/file-2')
89
 
        self.failUnlessExists('checkout/file-3')
 
87
        self.assertPathDoesNotExist('checkout/file-1')
 
88
        self.assertPathExists('checkout/file-2')
 
89
        self.assertPathExists('checkout/file-3')
90
90
 
91
91
    def test_switch_when_pending_merges(self):
92
92
        """Test graceful failure if pending merges are outstanding."""
120
120
        checkout = tree.branch.create_checkout('checkout',
121
121
            lightweight=self.lightweight)
122
122
        switch.switch(checkout.bzrdir, tree.branch, revision_id="rev1")
123
 
        self.failUnlessExists('checkout/file-1')
124
 
        self.failIfExists('checkout/file-2')
 
123
        self.assertPathExists('checkout/file-1')
 
124
        self.assertPathDoesNotExist('checkout/file-2')
125
125
 
126
126
    def test_switch_changing_root_id(self):
127
127
        tree = self._setup_tree()
179
179
        self.assertContainsRe(str(err),
180
180
            'Cannot switch as local commits found in the checkout.')
181
181
        # Check all is ok when force is given
182
 
        self.failIfExists('checkout/file-1')
183
 
        self.failUnlessExists('checkout/file-2')
 
182
        self.assertPathDoesNotExist('checkout/file-1')
 
183
        self.assertPathExists('checkout/file-2')
184
184
        switch.switch(checkout.bzrdir, to_branch, force=True)
185
 
        self.failUnlessExists('checkout/file-1')
186
 
        self.failIfExists('checkout/file-2')
187
 
        self.failIfExists('checkout/file-3')
188
 
        self.failUnlessExists('checkout/file-4')
 
185
        self.assertPathExists('checkout/file-1')
 
186
        self.assertPathDoesNotExist('checkout/file-2')
 
187
        self.assertPathDoesNotExist('checkout/file-3')
 
188
        self.assertPathExists('checkout/file-4')
189
189
        # Check that the checkout is a true mirror of the bound branch
190
190
        self.assertEqual(to_branch.last_revision_info(),
191
191
                         checkout.branch.last_revision_info())