1
# Copyright (C) 2005, 2006 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
from bzrlib.tests.blackbox import ExternalBase
21
from bzrlib.workingtree import WorkingTree
24
class TestRemove(ExternalBase):
26
def test_remove_deleted(self):
28
self.build_tree(['a'])
29
self.runbzr(['add', 'a'])
30
self.runbzr(['commit', '-m', 'added a'])
32
self.runbzr(['remove', 'a'])
34
def test_remove_new(self):
35
self.build_tree(['filefile',
38
wt = self.make_branch_and_tree('.')
39
wt.add(['filefile', 'dir', 'dir/filefilefile'],
40
['filefile-id', 'dir-id', 'filefilefile-id'])
41
self.assertEqual(wt.path2id('filefile'), 'filefile-id')
42
self.assertEqual(wt.path2id('dir/filefilefile'), 'filefilefile-id')
43
self.assertEqual(wt.path2id('dir'), 'dir-id')
44
self.runbzr('remove --new')
45
wt = WorkingTree.open('.')
46
self.assertIs(wt.path2id('filefile'), None)
47
self.assertIs(wt.path2id('dir/filefilefile'), None)
48
self.assertIs(wt.path2id('dir'), None)
49
wt.add(['filefile', 'dir', 'dir/filefilefile'],
50
['filefile-id', 'dir-id', 'filefilefile-id'])
51
self.assertEqual(wt.path2id('filefile'), 'filefile-id')
52
self.assertEqual(wt.path2id('dir/filefilefile'), 'filefilefile-id')
53
self.assertEqual(wt.path2id('dir'), 'dir-id')
54
self.runbzr('remove --new dir')
55
wt = WorkingTree.open('.')
56
self.assertEqual(wt.path2id('filefile'), 'filefile-id')
57
self.assertIs(wt.path2id('dir/filefilefile'), None)
58
self.assertIs(wt.path2id('dir'), None)
59
self.runbzr('remove --new .')
60
wt = WorkingTree.open('.')
61
self.assertIs(wt.path2id('filefile'), None)
62
self.runbzr('remove --new .', retcode=3)