1
# Copyright (C) 2008, 2009 Canonical Ltd
1
# Copyright (C) 2008 Canonical Ltd
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
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
19
from bzrlib import shelf
20
20
from bzrlib.tests import TestCaseWithTransport
21
from bzrlib.tests.script import ScriptRunner
24
22
class TestShelveList(TestCaseWithTransport):
28
26
err = self.run_bzr('shelve --list')[1]
29
27
self.assertEqual('No shelved changes.\n', err)
31
def make_creator(self, tree):
32
creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
33
self.addCleanup(creator.finalize)
36
29
def test_shelve_one(self):
37
30
tree = self.make_branch_and_tree('.')
38
creator = self.make_creator(tree)
31
creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
39
32
shelf_id = tree.get_shelf_manager().shelve_changes(creator, 'Foo')
40
33
out, err = self.run_bzr('shelve --list', retcode=1)
41
34
self.assertEqual('', err)
44
37
def test_shelve_no_message(self):
45
38
tree = self.make_branch_and_tree('.')
46
creator = self.make_creator(tree)
39
creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
47
40
shelf_id = tree.get_shelf_manager().shelve_changes(creator)
48
41
out, err = self.run_bzr('shelve --list', retcode=1)
49
42
self.assertEqual('', err)
52
45
def test_shelf_order(self):
53
46
tree = self.make_branch_and_tree('.')
54
creator = self.make_creator(tree)
47
creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
55
48
tree.get_shelf_manager().shelve_changes(creator, 'Foo')
56
creator = self.make_creator(tree)
49
creator = shelf.ShelfCreator(tree, tree.basis_tree(), [])
57
50
tree.get_shelf_manager().shelve_changes(creator, 'Bar')
58
51
out, err = self.run_bzr('shelve --list', retcode=1)
59
52
self.assertEqual('', err)
60
53
self.assertEqual(' 2: Bar\n 1: Foo\n', out)
62
def test_shelve_destroy(self):
63
tree = self.make_branch_and_tree('.')
64
self.build_tree(['file'])
66
self.run_bzr('shelve --all --destroy')
67
self.failIfExists('file')
68
self.assertIs(None, tree.get_shelf_manager().last_shelf())
70
def test_unshelve_keep(self):
71
# https://bugs.edge.launchpad.net/bzr/+bug/492091
72
tree = self.make_branch_and_tree('.')
73
# shelve apparently unhappy working with a tree with no root yet
74
tree.commit('make root')
75
self.build_tree(['file'])
78
sr.run_script(self, '''
80
$ bzr shelve --all -m Foo
92
56
class TestShelveRelpath(TestCaseWithTransport):