5
5
from bzrlib.branch import Branch
6
6
from bzrlib.errors import NotBranchError, NotVersionedError
8
class TestSmartAdd(FunctionalTestCase):
10
def test_add_dot_from_root(self):
11
"""Test adding . from the root of the tree."""
12
from bzrlib.add import smart_add
13
paths = ("original/", "original/file1", "original/file2")
14
self.build_tree(paths)
15
branch = Branch(".", init=True)
16
smart_add((".",), False, True)
18
self.assertNotEqual(branch.inventory.path2id(path), None)
20
def test_add_dot_from_subdir(self):
21
"""Test adding . from a subdir of the tree."""
22
from bzrlib.add import smart_add
23
paths = ("original/", "original/file1", "original/file2")
24
self.build_tree(paths)
25
branch = Branch(".", init=True)
27
smart_add((".",), False, True)
29
self.assertNotEqual(branch.inventory.path2id(path), None)
31
def test_add_tree_from_above_tree(self):
32
"""Test adding a tree from above the tree."""
33
from bzrlib.add import smart_add
34
paths = ("original/", "original/file1", "original/file2")
35
branch_paths = ("branch/", "branch/original/", "branch/original/file1", "branch/original/file2")
36
self.build_tree(branch_paths)
37
branch = Branch("branch", init=True)
38
smart_add(("branch",), False, True)
40
self.assertNotEqual(branch.inventory.path2id(path), None)
42
def test_add_above_tree_preserves_tree(self):
43
"""Test nested trees are not affect by an add above them."""
44
from bzrlib.add import smart_add
45
paths = ("original/", "original/file1", "original/file2")
46
child_paths = ("path")
47
full_child_paths = ("original/child", "original/child/path")
48
build_paths = ("original/", "original/file1", "original/file2",
49
"original/child/", "original/child/path")
50
self.build_tree(build_paths)
51
branch = Branch(".", init=True)
52
child_branch = Branch("original/child", init=True)
53
smart_add((".",), False, True)
55
self.assertNotEqual((path, branch.inventory.path2id(path)),
57
for path in full_child_paths:
58
self.assertEqual((path, branch.inventory.path2id(path)),
60
for path in child_paths:
61
self.assertEqual(child_branch.inventory.path2id(path), None)