~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_switch.py

  • Committer: Aaron Bentley
  • Date: 2012-07-18 18:30:48 UTC
  • mto: This revision was merged to the branch mainline in revision 6540.
  • Revision ID: aaron@aaronbentley.com-20120718183048-rr45kn62nh6m24vv
Restore uncommitted changes even if revisions are same.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        tree.commit('rev1')
51
51
        return tree
52
52
 
53
 
    def _setup_uncommitted(self):
 
53
    def _setup_uncommitted(self, same_revision=False):
54
54
        tree = self._setup_tree()
55
55
        to_branch = tree.bzrdir.sprout('branch-2').open_branch()
56
56
        self.build_tree(['branch-1/file-2'])
57
 
        tree.add('file-2')
58
 
        tree.remove('file-1')
59
 
        tree.commit('rev2')
 
57
        if not same_revision:
 
58
            tree.add('file-2')
 
59
            tree.remove('file-1')
 
60
            tree.commit('rev2')
60
61
        checkout = tree.branch.create_checkout('checkout',
61
62
            lightweight=self.lightweight)
62
63
        self.build_tree(['checkout/file-3'])
87
88
        self.assertPathExists('checkout/file-2')
88
89
        self.assertPathExists('checkout/file-3')
89
90
 
 
91
    def test_switch_restore_uncommitted_same_revision(self):
 
92
        """Test switch updates tree and restores uncommitted changes."""
 
93
        checkout, to_branch = self._setup_uncommitted(same_revision=True)
 
94
        old_branch = self._master_if_present(checkout.branch)
 
95
        switch.switch(checkout.bzrdir, to_branch, store_uncommitted=True)
 
96
        checkout = workingtree.WorkingTree.open('checkout')
 
97
        switch.switch(checkout.bzrdir, old_branch, store_uncommitted=True)
 
98
        self.assertPathExists('checkout/file-3')
 
99
 
90
100
    def test_switch_updates(self):
91
101
        """Test switch updates tree and keeps uncommitted changes."""
92
102
        checkout, to_branch = self._setup_uncommitted()