~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_smart_add.py

  • Committer: Robert Collins
  • Date: 2005-08-25 01:13:32 UTC
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050825011331-6d549d5de7edcec1
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
from bzrlib.branch import Branch
6
6
from bzrlib.errors import NotBranchError, NotVersionedError
7
7
 
8
 
 
 
8
class TestSmartAdd(FunctionalTestCase):
 
9
 
 
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)
 
17
        for path in paths:
 
18
            self.assertNotEqual(branch.inventory.path2id(path), None)
 
19
 
 
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)
 
26
        os.chdir("original")
 
27
        smart_add((".",), False, True)
 
28
        for path in paths:
 
29
            self.assertNotEqual(branch.inventory.path2id(path), None)
 
30
 
 
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)
 
39
        for path in paths:
 
40
            self.assertNotEqual(branch.inventory.path2id(path), None)
 
41
 
 
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)
 
54
        for path in paths:
 
55
            self.assertNotEqual((path, branch.inventory.path2id(path)),
 
56
                                (path, None))
 
57
        for path in full_child_paths:
 
58
            self.assertEqual((path, branch.inventory.path2id(path)),
 
59
                             (path, None))
 
60
        for path in child_paths:
 
61
            self.assertEqual(child_branch.inventory.path2id(path), None)