1
# Copyright (C) 2007 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
17
"""Test that we can use smart_add on all Tree implementations."""
24
from bzrlib.add import (
31
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
34
class TestSmartAddTree(TestCaseWithWorkingTree):
36
def test_single_file(self):
37
tree = self.make_branch_and_tree('tree')
38
self.build_tree(['tree/a'])
39
add.smart_add_tree(tree, ['tree'])
43
files = [(path, status, kind)
44
for path, status, kind, file_id, parent_id
45
in tree.list_files(include_root=True)]
48
self.assertEqual([('', 'V', 'directory'), ('a', 'V', 'file')],
51
def test_save_false(self):
52
"""Dry-run add doesn't permanently affect the tree."""
53
wt = self.make_branch_and_tree('.')
54
self.build_tree(['file'])
55
smart_add_tree(wt, ['file'], save=False)
56
# The in-memory inventory is left modified in inventory-based trees;
57
# it may not be in dirstate trees. Anyhow, now we reload to make sure
58
# the on-disk version is not modified.
59
wt = wt.bzrdir.open_workingtree()
60
self.assertEqual(wt.path2id('file'), None)