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())
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)
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')
535
shelf.ShelfCreator._write_shelf(s, tt, tree.last_revision())
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())
530
def test_restore_uncommitted_none(self):
531
tree = self.make_branch_and_tree('tree')
532
tree.restore_uncommitted()
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())