~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:30:43 UTC
  • Revision ID: mbp@sourcefrog.net-20050830053042-58932432ee958d1e
- make get_parent() be a method of Branch; add simple tests for it

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.initialize(".")
16
 
        smart_add((".",), recurse=True)
 
15
        branch = Branch(".", init=True)
 
16
        smart_add((".",), False, 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.initialize(".")
 
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
 
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.initialize("branch")
39
 
        smart_add(("branch",))
 
38
        branch = Branch("branch", init=True)
 
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")
51
50
                       "original/child/", "original/child/path")
52
51
        
53
52
        self.build_tree(build_paths)
54
 
        branch = Branch.initialize(".")
55
 
        child_branch = Branch.initialize("original/child")
56
 
        smart_add((".",), True, add_reporter_null)
 
53
        branch = Branch(".", init=True)
 
54
        child_branch = Branch("original/child", init=True)
 
55
        smart_add((".",), False, True)
57
56
        for path in paths:
58
57
            self.assertNotEqual((path, branch.inventory.path2id(path)),
59
58
                                (path, None))
68
67
        from bzrlib.add import smart_add
69
68
        paths = ("file1", "file2")
70
69
        self.build_tree(paths)
71
 
        branch = Branch.initialize(".")
72
 
        smart_add(paths)
 
70
        branch = Branch(".", init=True)
 
71
        smart_add(paths, False, True)
73
72
        for path in paths:
74
73
            self.assertNotEqual(branch.inventory.path2id(path), None)
75
74
            
81
80
        from bzrlib.add import smart_add_branch
82
81
        paths = ("original/", "original/file1", "original/file2")
83
82
        self.build_tree(paths)
84
 
        branch = Branch.initialize(".")
85
 
        smart_add_branch(branch, (".",))
 
83
        branch = Branch(".", init=True)
 
84
        smart_add_branch(branch, (".",), False, True)
86
85
        for path in paths:
87
86
            self.assertNotEqual(branch.inventory.path2id(path), None)
88
87
 
91
90
        from bzrlib.add import smart_add_branch
92
91
        paths = ("original/", "original/file1", "original/file2")
93
92
        self.build_tree(paths)
94
 
        branch = Branch.initialize(".")
 
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
 
104
103
        branch_paths = ("branch/", "branch/original/", "branch/original/file1",
105
104
                        "branch/original/file2")
106
105
        self.build_tree(branch_paths)
107
 
        branch = Branch.initialize("branch")
108
 
        smart_add_branch(branch, ("branch",))
 
106
        branch = Branch("branch", init=True)
 
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
 
118
117
        build_paths = ("original/", "original/file1", "original/file2", 
119
118
                       "original/child/", "original/child/path")
120
119
        self.build_tree(build_paths)
121
 
        branch = Branch.initialize(".")
122
 
        child_branch = Branch.initialize("original/child")
123
 
        smart_add_branch(branch, (".",))
 
120
        branch = Branch(".", init=True)
 
121
        child_branch = Branch("original/child", init=True)
 
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))
135
134
        from bzrlib.add import smart_add_branch
136
135
        paths = ("file1", "file2")
137
136
        self.build_tree(paths)
138
 
        branch = Branch.initialize(".")
139
 
        smart_add_branch(branch, paths)
 
137
        branch = Branch(".", init=True)
 
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")