~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/versioning.py

[merge] up-to-date against bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import os
24
24
 
25
 
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
 
25
from bzrlib.tests import BzrTestBase, TestCaseInTempDir
26
26
from bzrlib.branch import Branch
27
27
from bzrlib.trace import mutter
28
28
 
113
113
        self.assertEquals(delta.added[0][0], 'dir')
114
114
        self.failIf(delta.modified)
115
115
 
116
 
    def test_branch_add_in_unversioned(self):
 
116
    def test_working_tree_add_in_unversioned(self):
117
117
        """Try to add a file in an unversioned directory.
118
118
 
119
 
        "bzr add" adds the parent as necessary, but simple branch add
 
119
        "bzr add" adds the parent as necessary, but simple working tree add
120
120
        doesn't do that.
121
121
        """
122
122
        from bzrlib.branch import Branch
123
123
        from bzrlib.errors import NotVersionedError
 
124
        from bzrlib.workingtree import WorkingTree
124
125
 
125
126
        b = Branch.initialize('.')
126
127
 
128
129
                         'foo/hello'])
129
130
 
130
131
        self.assertRaises(NotVersionedError,
131
 
                          b.add,
 
132
                          WorkingTree(b.base, b).add,
132
133
                          'foo/hello')
133
134
        
134
135
        self.check_branch()
135
136
 
136
 
    def test_add_in_unversioned(self):
137
 
        """Try to add a file in an unversioned directory.
138
 
 
139
 
        "bzr add" should add the parent(s) as necessary.
140
 
        """
141
 
        from bzrlib.branch import Branch
142
 
        eq = self.assertEqual
143
 
 
144
 
        b = Branch.initialize('.')
145
 
 
146
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
147
 
        eq(list(b.unknowns()), ['inertiatic'])
148
 
        self.run_bzr('add', 'inertiatic/esp')
149
 
        eq(list(b.unknowns()), [])
150
 
 
151
 
        # Multiple unversioned parents
152
 
        self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
153
 
        eq(list(b.unknowns()), ['veil'])
154
 
        self.run_bzr('add', 'veil/cerpin/taxt')
155
 
        eq(list(b.unknowns()), [])
156
 
 
157
 
        # Check whacky paths work
158
 
        self.build_tree(['cicatriz/', 'cicatriz/esp'])
159
 
        eq(list(b.unknowns()), ['cicatriz'])
160
 
        self.run_bzr('add', 'inertiatic/../cicatriz/esp')
161
 
        eq(list(b.unknowns()), [])
162
 
 
163
 
    def test_add_in_versioned(self):
164
 
        """Try to add a file in a versioned directory.
165
 
 
166
 
        "bzr add" should do this happily.
167
 
        """
168
 
        from bzrlib.branch import Branch
169
 
        eq = self.assertEqual
170
 
 
171
 
        b = Branch.initialize('.')
172
 
 
173
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
174
 
        eq(list(b.unknowns()), ['inertiatic'])
175
 
        self.run_bzr('add', '--no-recurse', 'inertiatic')
176
 
        eq(list(b.unknowns()), ['inertiatic'+os.sep+'esp'])
177
 
        self.run_bzr('add', 'inertiatic/esp')
178
 
        eq(list(b.unknowns()), [])
179
 
 
180
 
    def test_subdir_add(self):
181
 
        """Add in subdirectory should add only things from there down"""
182
 
        
183
 
        from bzrlib.branch import Branch
184
 
        
185
 
        eq = self.assertEqual
186
 
        ass = self.assert_
187
 
        chdir = os.chdir
188
 
        
189
 
        b = Branch.initialize('.')
190
 
        t = b.working_tree()
191
 
        self.build_tree(['src/', 'README'])
192
 
        
193
 
        eq(sorted(b.unknowns()),
194
 
           ['README', 'src'])
195
 
        
196
 
        self.run_bzr('add', 'src')
197
 
        
198
 
        self.build_tree(['src/foo.c'])
199
 
        
200
 
        chdir('src')
201
 
        self.run_bzr('add')
202
 
        
203
 
        eq(sorted(b.unknowns()), 
204
 
           ['README'])
205
 
        eq(len(t.read_working_inventory()), 3)
206
 
                
207
 
        chdir('..')
208
 
        self.run_bzr('add')
209
 
        eq(list(b.unknowns()), [])
210
 
 
211
 
        self.check_branch()
212
 
 
213
137
    def check_branch(self):
214
138
        """After all the above changes, run the check and upgrade commands.
215
139