~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_smart_add.py

Heikki Paajanen's status -r patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
        from bzrlib.add import smart_add
13
13
        paths = ("original/", "original/file1", "original/file2")
14
14
        self.build_tree(paths)
15
 
        branch = Branch(".", init=True)
16
 
        smart_add((".",), False, True)
 
15
        branch = Branch.initialize(".")
 
16
        smart_add((".",), recurse=True)
17
17
        for path in paths:
18
18
            self.assertNotEqual(branch.inventory.path2id(path), None)
19
19
 
22
22
        from bzrlib.add import smart_add
23
23
        paths = ("original/", "original/file1", "original/file2")
24
24
        self.build_tree(paths)
25
 
        branch = Branch(".", init=True)
 
25
        branch = Branch.initialize(".")
26
26
        os.chdir("original")
27
 
        smart_add((".",), False, True)
 
27
        smart_add((".",), recurse=True)
28
28
        for path in paths:
29
29
            self.assertNotEqual(branch.inventory.path2id(path), None)
30
30
 
35
35
        branch_paths = ("branch/", "branch/original/", "branch/original/file1",
36
36
                        "branch/original/file2")
37
37
        self.build_tree(branch_paths)
38
 
        branch = Branch("branch", init=True)
39
 
        smart_add(("branch",), False, True)
 
38
        branch = Branch.initialize("branch")
 
39
        smart_add(("branch",))
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
 
45
        from bzrlib.add import smart_add, add_reporter_null
 
46
        
46
47
        paths = ("original/", "original/file1", "original/file2")
47
 
        child_paths = ("path")
 
48
        child_paths = ("path",)
48
49
        full_child_paths = ("original/child", "original/child/path")
49
50
        build_paths = ("original/", "original/file1", "original/file2", 
50
51
                       "original/child/", "original/child/path")
 
52
        
51
53
        self.build_tree(build_paths)
52
 
        branch = Branch(".", init=True)
53
 
        child_branch = Branch("original/child", init=True)
54
 
        smart_add((".",), False, True)
 
54
        branch = Branch.initialize(".")
 
55
        child_branch = Branch.initialize("original/child")
 
56
        smart_add((".",), True, add_reporter_null)
55
57
        for path in paths:
56
58
            self.assertNotEqual((path, branch.inventory.path2id(path)),
57
59
                                (path, None))
66
68
        from bzrlib.add import smart_add
67
69
        paths = ("file1", "file2")
68
70
        self.build_tree(paths)
69
 
        branch = Branch(".", init=True)
70
 
        smart_add(paths, False, True)
 
71
        branch = Branch.initialize(".")
 
72
        smart_add(paths)
71
73
        for path in paths:
72
74
            self.assertNotEqual(branch.inventory.path2id(path), None)
73
75
            
79
81
        from bzrlib.add import smart_add_branch
80
82
        paths = ("original/", "original/file1", "original/file2")
81
83
        self.build_tree(paths)
82
 
        branch = Branch(".", init=True)
83
 
        smart_add_branch(branch, (".",), False, True)
 
84
        branch = Branch.initialize(".")
 
85
        smart_add_branch(branch, (".",))
84
86
        for path in paths:
85
87
            self.assertNotEqual(branch.inventory.path2id(path), None)
86
88
 
89
91
        from bzrlib.add import smart_add_branch
90
92
        paths = ("original/", "original/file1", "original/file2")
91
93
        self.build_tree(paths)
92
 
        branch = Branch(".", init=True)
 
94
        branch = Branch.initialize(".")
93
95
        os.chdir("original")
94
 
        smart_add_branch(branch, (".",), False, True)
 
96
        smart_add_branch(branch, (".",))
95
97
        for path in paths:
96
98
            self.assertNotEqual(branch.inventory.path2id(path), None)
97
99
 
102
104
        branch_paths = ("branch/", "branch/original/", "branch/original/file1",
103
105
                        "branch/original/file2")
104
106
        self.build_tree(branch_paths)
105
 
        branch = Branch("branch", init=True)
106
 
        smart_add_branch(branch, ("branch",), False, True)
 
107
        branch = Branch.initialize("branch")
 
108
        smart_add_branch(branch, ("branch",))
107
109
        for path in paths:
108
110
            self.assertNotEqual(branch.inventory.path2id(path), None)
109
111
 
116
118
        build_paths = ("original/", "original/file1", "original/file2", 
117
119
                       "original/child/", "original/child/path")
118
120
        self.build_tree(build_paths)
119
 
        branch = Branch(".", init=True)
120
 
        child_branch = Branch("original/child", init=True)
121
 
        smart_add_branch(branch, (".",), False, True)
 
121
        branch = Branch.initialize(".")
 
122
        child_branch = Branch.initialize("original/child")
 
123
        smart_add_branch(branch, (".",))
122
124
        for path in paths:
123
125
            self.assertNotEqual((path, branch.inventory.path2id(path)),
124
126
                                (path, None))
133
135
        from bzrlib.add import smart_add_branch
134
136
        paths = ("file1", "file2")
135
137
        self.build_tree(paths)
136
 
        branch = Branch(".", init=True)
137
 
        smart_add_branch(branch, paths, False, True)
 
138
        branch = Branch.initialize(".")
 
139
        smart_add_branch(branch, paths)
138
140
        for path in paths:
139
141
            self.assertNotEqual(branch.inventory.path2id(path), None)
140
142
 
146
148
        self.entry = InventoryEntry("id", "name", "file", None)
147
149
 
148
150
    def test_null_callback(self):
149
 
        from bzrlib.add import _NullAddCallback
150
 
        _NullAddCallback('path', 'file', self.entry)
 
151
        from bzrlib.add import add_reporter_null
 
152
        add_reporter_null('path', 'file', self.entry)
151
153
 
152
154
    def test_print_callback(self):
153
 
        from bzrlib.add import _PrintAddCallback
 
155
        from bzrlib.add import add_reporter_print
154
156
        from StringIO import StringIO
155
157
        stdout = StringIO()
156
 
        self.apply_redirected(None, stdout, None, _PrintAddCallback,
 
158
        self.apply_redirected(None, stdout, None, add_reporter_print,
157
159
                              'path', 'file', self.entry)
158
160
        self.assertEqual(stdout.getvalue(), "added path\n")