~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_smart_add.py

  • Committer: Martin Pool
  • Date: 2005-08-30 05:35:11 UTC
  • Revision ID: mbp@sourcefrog.net-20050830053511-71f6b3ba8ca93827
- add new Branch.set_parent and tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
        paths = ("original/", "original/file1", "original/file2")
14
14
        self.build_tree(paths)
15
15
        branch = Branch(".", init=True)
16
 
        smart_add((".",), recurse=True)
 
16
        smart_add((".",), False, True)
17
17
        for path in paths:
18
18
            self.assertNotEqual(branch.inventory.path2id(path), None)
19
19
 
24
24
        self.build_tree(paths)
25
25
        branch = Branch(".", init=True)
26
26
        os.chdir("original")
27
 
        smart_add((".",), recurse=True)
 
27
        smart_add((".",), False, True)
28
28
        for path in paths:
29
29
            self.assertNotEqual(branch.inventory.path2id(path), None)
30
30
 
36
36
                        "branch/original/file2")
37
37
        self.build_tree(branch_paths)
38
38
        branch = Branch("branch", init=True)
39
 
        smart_add(("branch",))
 
39
        smart_add(("branch",), False, True)
40
40
        for path in paths:
41
41
            self.assertNotEqual(branch.inventory.path2id(path), None)
42
42
 
43
43
    def test_add_above_tree_preserves_tree(self):
44
44
        """Test nested trees are not affect by an add above them."""
45
 
        from bzrlib.add import smart_add, add_reporter_null
46
 
        
 
45
        from bzrlib.add import smart_add
47
46
        paths = ("original/", "original/file1", "original/file2")
48
47
        child_paths = ("path",)
49
48
        full_child_paths = ("original/child", "original/child/path")
53
52
        self.build_tree(build_paths)
54
53
        branch = Branch(".", init=True)
55
54
        child_branch = Branch("original/child", init=True)
56
 
        smart_add((".",), True, add_reporter_null)
 
55
        smart_add((".",), False, True)
57
56
        for path in paths:
58
57
            self.assertNotEqual((path, branch.inventory.path2id(path)),
59
58
                                (path, None))
69
68
        paths = ("file1", "file2")
70
69
        self.build_tree(paths)
71
70
        branch = Branch(".", init=True)
72
 
        smart_add(paths)
 
71
        smart_add(paths, False, True)
73
72
        for path in paths:
74
73
            self.assertNotEqual(branch.inventory.path2id(path), None)
75
74
            
82
81
        paths = ("original/", "original/file1", "original/file2")
83
82
        self.build_tree(paths)
84
83
        branch = Branch(".", init=True)
85
 
        smart_add_branch(branch, (".",))
 
84
        smart_add_branch(branch, (".",), False, True)
86
85
        for path in paths:
87
86
            self.assertNotEqual(branch.inventory.path2id(path), None)
88
87
 
93
92
        self.build_tree(paths)
94
93
        branch = Branch(".", init=True)
95
94
        os.chdir("original")
96
 
        smart_add_branch(branch, (".",))
 
95
        smart_add_branch(branch, (".",), False, True)
97
96
        for path in paths:
98
97
            self.assertNotEqual(branch.inventory.path2id(path), None)
99
98
 
105
104
                        "branch/original/file2")
106
105
        self.build_tree(branch_paths)
107
106
        branch = Branch("branch", init=True)
108
 
        smart_add_branch(branch, ("branch",))
 
107
        smart_add_branch(branch, ("branch",), False, True)
109
108
        for path in paths:
110
109
            self.assertNotEqual(branch.inventory.path2id(path), None)
111
110
 
120
119
        self.build_tree(build_paths)
121
120
        branch = Branch(".", init=True)
122
121
        child_branch = Branch("original/child", init=True)
123
 
        smart_add_branch(branch, (".",))
 
122
        smart_add_branch(branch, (".",), False, True)
124
123
        for path in paths:
125
124
            self.assertNotEqual((path, branch.inventory.path2id(path)),
126
125
                                (path, None))
136
135
        paths = ("file1", "file2")
137
136
        self.build_tree(paths)
138
137
        branch = Branch(".", init=True)
139
 
        smart_add_branch(branch, paths)
 
138
        smart_add_branch(branch, paths, False, True)
140
139
        for path in paths:
141
140
            self.assertNotEqual(branch.inventory.path2id(path), None)
142
141
 
148
147
        self.entry = InventoryEntry("id", "name", "file", None)
149
148
 
150
149
    def test_null_callback(self):
151
 
        from bzrlib.add import add_reporter_null
152
 
        add_reporter_null('path', 'file', self.entry)
 
150
        from bzrlib.add import _NullAddCallback
 
151
        _NullAddCallback('path', 'file', self.entry)
153
152
 
154
153
    def test_print_callback(self):
155
 
        from bzrlib.add import add_reporter_print
 
154
        from bzrlib.add import _PrintAddCallback
156
155
        from StringIO import StringIO
157
156
        stdout = StringIO()
158
 
        self.apply_redirected(None, stdout, None, add_reporter_print,
 
157
        self.apply_redirected(None, stdout, None, _PrintAddCallback,
159
158
                              'path', 'file', self.entry)
160
159
        self.assertEqual(stdout.getvalue(), "added path\n")