~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_move.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-01 06:48:38 UTC
  • mfrom: (2389.1.1 0.15-to-trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20070401064838-34903c7b0d0c8007
merge 0.15 back to dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        tree.commit('initial commit')
55
55
        self.assertEqual([('a1', 'sub1/a1')],
56
56
            tree.move(['a1'], to_dir='sub1', after=False))
 
57
        tree._validate()
57
58
 
58
59
    def test_move_correct_call_unnamed(self):
59
60
        """tree.move has the deprecated parameter 'to_name'.
66
67
        tree.commit('initial commit')
67
68
        self.assertEqual([('a1', 'sub1/a1')],
68
69
            tree.move(['a1'], 'sub1', after=False))
 
70
        tree._validate()
69
71
 
70
72
    def test_move_deprecated_wrong_call(self):
71
73
        """tree.move has the deprecated parameter 'to_name'.
79
81
        self.assertRaises(TypeError, tree.move, ['a1'],
80
82
                          to_this_parameter_does_not_exist='sub1',
81
83
                          after=False)
 
84
        tree._validate()
82
85
 
83
86
    def test_move_deprecated_call(self):
84
87
        """tree.move has the deprecated parameter 'to_name'.
100
103
            # since it was deprecated before the class was introduced.
101
104
            if not isinstance(self.workingtree_format, WorkingTreeFormat4):
102
105
                raise
 
106
        tree._validate()
103
107
 
104
108
    def test_move_target_not_dir(self):
105
109
        tree = self.make_branch_and_tree('.')
109
113
 
110
114
        self.assertRaises(errors.BzrMoveFailedError,
111
115
                          tree.move, ['a'], 'not-a-dir')
 
116
        tree._validate()
112
117
 
113
118
    def test_move_non_existent(self):
114
119
        tree = self.make_branch_and_tree('.')
119
124
                          tree.move, ['not-a-file'], 'a')
120
125
        self.assertRaises(errors.BzrMoveFailedError,
121
126
                          tree.move, ['not-a-file'], '')
 
127
        tree._validate()
122
128
 
123
129
    def test_move_target_not_versioned(self):
124
130
        tree = self.make_branch_and_tree('.')
127
133
        tree.commit('initial', rev_id='rev-1')
128
134
        self.assertRaises(errors.BzrMoveFailedError,
129
135
                          tree.move, ['b'], 'a')
 
136
        tree._validate()
130
137
 
131
138
    def test_move_unversioned(self):
132
139
        tree = self.make_branch_and_tree('.')
135
142
        tree.commit('initial', rev_id='rev-1')
136
143
        self.assertRaises(errors.BzrMoveFailedError,
137
144
                          tree.move, ['b'], 'a')
 
145
        tree._validate()
138
146
 
139
147
    def test_move_multi_unversioned(self):
140
148
        tree = self.make_branch_and_tree('.')
157
165
                                   ('d', 'd-id')], tree)
158
166
        self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'),
159
167
                               ('d', 'd-id')], tree.basis_tree())
 
168
        tree._validate()
160
169
 
161
170
    def test_move_subdir(self):
162
171
        tree = self.make_branch_and_tree('.')
177
186
                               ('b/c', 'c-id')], tree.basis_tree())
178
187
        self.failIfExists('a')
179
188
        self.assertFileEqual(a_contents, 'b/a')
 
189
        tree._validate()
180
190
 
181
191
    def test_move_parent_dir(self):
182
192
        tree = self.make_branch_and_tree('.')
193
203
                               ('b/c', 'c-id')], tree.basis_tree())
194
204
        self.failIfExists('b/c')
195
205
        self.assertFileEqual(c_contents, 'c')
 
206
        tree._validate()
196
207
 
197
208
    def test_move_fail_consistent(self):
198
209
        tree = self.make_branch_and_tree('.')
214
225
                                   ('b/c', 'c-id')], tree)
215
226
        self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
216
227
                               ('c', 'c-id')], tree.basis_tree())
 
228
        tree._validate()
217
229
 
218
230
    def test_move_onto_self(self):
219
231
        tree = self.make_branch_and_tree('.')
223
235
 
224
236
        self.assertRaises(errors.BzrMoveFailedError,
225
237
                          tree.move, ['b/a'], 'b')
 
238
        tree._validate()
226
239
 
227
240
    def test_move_onto_self_root(self):
228
241
        tree = self.make_branch_and_tree('.')
232
245
 
233
246
        self.assertRaises(errors.BzrMoveFailedError,
234
247
                          tree.move, ['a'], 'a')
 
248
        tree._validate()
235
249
 
236
250
    def test_move_after(self):
237
251
        tree = self.make_branch_and_tree('.')
251
265
                              tree)
252
266
        self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
253
267
                              tree.basis_tree())
 
268
        tree._validate()
254
269
 
255
270
    def test_move_after_with_after(self):
256
271
        tree = self.make_branch_and_tree('.')
269
284
                              tree)
270
285
        self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
271
286
                              tree.basis_tree())
 
287
        tree._validate()
272
288
 
273
289
    def test_move_after_no_target(self):
274
290
        tree = self.make_branch_and_tree('.')
282
298
                          tree.move, ['a'], 'b', after=True)
283
299
        self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
284
300
                              tree.basis_tree())
 
301
        tree._validate()
285
302
 
286
303
    def test_move_after_source_and_dest(self):
287
304
        tree = self.make_branch_and_tree('.')
321
338
        # But it shouldn't actually move anything
322
339
        self.assertFileEqual(a_text, 'a')
323
340
        self.assertFileEqual(ba_text, 'b/a')
 
341
        tree._validate()
324
342
 
325
343
    def test_move_directory(self):
326
344
        tree = self.make_branch_and_tree('.')
338
356
        self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('e', 'e-id'),
339
357
                               ('a/b', 'b-id'), ('a/c', 'c-id'),
340
358
                               ('a/c/d', 'd-id')], tree.basis_tree())
 
359
        tree._validate()
341
360
 
342
361
    def test_move_moved(self):
343
362
        """Moving a moved entry works as expected."""
360
379
                               ('c', 'c-id')], tree)
361
380
        self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'),
362
381
                               ('a/b', 'b-id')], tree.basis_tree())
 
382
        tree._validate()