~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Aaron Bentley
  • Date: 2012-07-13 19:32:33 UTC
  • mto: This revision was merged to the branch mainline in revision 6540.
  • Revision ID: aaron@aaronbentley.com-20120713193233-l6y0l0twwhd3wmka
Switch to much simpler implementation of restore_uncommitted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    workingtree_3,
28
28
    workingtree_4,
29
29
    )
 
30
from bzrlib.lock import write_locked
30
31
from bzrlib.lockdir import LockDir
31
32
from bzrlib.mutabletree import needs_tree_write_lock
32
33
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
520
521
        tree.store_uncommitted()
521
522
        self.assertFalse(tree.branch.has_stored_uncommitted())
522
523
 
523
 
    def test_get_uncommitted_data_none(self):
524
 
        tree = self.make_branch_and_tree('tree')
525
 
        base_tree, tt = tree.get_uncommitted_data()
526
 
        self.assertIs(None, base_tree)
527
 
        self.assertIs(None, tt)
528
 
 
529
 
    def test_get_uncommitted_data(self):
530
 
        tree = self.make_branch_and_tree('tree')
531
 
        tree.commit('add root')
532
 
        with TransformPreview(tree.basis_tree()) as tt:
533
 
            tt.new_directory('not_root', tt.root, 'not-root')
534
 
            s = StringIO()
535
 
            shelf.ShelfCreator._write_shelf(s, tt, tree.last_revision())
536
 
        s.seek(0)
537
 
        tree.branch._put_uncommitted(s)
538
 
        base_tree, tt = tree.get_uncommitted_data()
539
 
        self.addCleanup(tt.finalize)
540
 
        self.assertEqual('not-root', tt.get_preview_tree().path2id('not_root'))
 
524
    def test_restore_uncommitted(self):
 
525
        with write_locked(self.store_uncommitted()) as tree:
 
526
            tree.restore_uncommitted()
 
527
            self.assertPathExists('tree/file')
 
528
            self.assertFalse(None, tree.branch.has_stored_uncommitted())
 
529
 
 
530
    def test_restore_uncommitted_none(self):
 
531
        tree = self.make_branch_and_tree('tree')
 
532
        tree.restore_uncommitted()
 
533
 
 
534
    def test_restore_uncommitted_no_delete(self):
 
535
        with write_locked(self.store_uncommitted()) as tree:
 
536
            tree.restore_uncommitted(delete=False)
 
537
            self.assertTrue(tree.branch.has_stored_uncommitted())