/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/blackbox/test_mv.py

  • Committer: Jelmer Vernooij
  • Date: 2018-07-08 14:45:27 UTC
  • mto: This revision was merged to the branch mainline in revision 7036.
  • Revision ID: jelmer@jelmer.uk-20180708144527-codhlvdcdg9y0nji
Fix a bunch of merge tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Test for 'bzr mv'"""
 
17
"""Test for 'brz mv'"""
18
18
 
19
19
import os
20
20
 
21
 
import bzrlib.branch
22
 
from bzrlib import (
 
21
import breezy.branch
 
22
from breezy import (
23
23
    osutils,
24
24
    workingtree,
25
25
    )
26
26
 
27
 
from bzrlib.tests import (
 
27
from breezy.tests import (
 
28
    TestCaseWithTransport,
 
29
    )
 
30
from breezy.tests.features import (
28
31
    CaseInsensitiveFilesystemFeature,
29
32
    SymlinkFeature,
30
 
    TestCaseWithTransport,
 
33
    UnicodeFilenameFeature,
31
34
    )
32
35
 
33
36
 
34
37
class TestMove(TestCaseWithTransport):
35
38
 
36
 
    def assertMoved(self,from_path,to_path):
 
39
    def assertMoved(self, from_path, to_path):
37
40
        """Assert that to_path is existing and versioned but from_path not. """
38
 
        self.failIfExists(from_path)
 
41
        self.assertPathDoesNotExist(from_path)
39
42
        self.assertNotInWorkingTree(from_path)
40
43
 
41
 
        self.failUnlessExists(to_path)
 
44
        self.assertPathExists(to_path)
42
45
        self.assertInWorkingTree(to_path)
43
46
 
44
47
    def test_mv_modes(self):
48
51
        tree.add(['a', 'c', 'subdir'])
49
52
 
50
53
        self.run_bzr('mv a b')
51
 
        self.assertMoved('a','b')
 
54
        self.assertMoved('a', 'b')
52
55
 
53
56
        self.run_bzr('mv b subdir')
54
 
        self.assertMoved('b','subdir/b')
 
57
        self.assertMoved('b', 'subdir/b')
55
58
 
56
59
        self.run_bzr('mv subdir/b a')
57
 
        self.assertMoved('subdir/b','a')
 
60
        self.assertMoved('subdir/b', 'a')
58
61
 
59
62
        self.run_bzr('mv a c subdir')
60
 
        self.assertMoved('a','subdir/a')
61
 
        self.assertMoved('c','subdir/c')
 
63
        self.assertMoved('a', 'subdir/a')
 
64
        self.assertMoved('c', 'subdir/c')
62
65
 
63
66
        self.run_bzr('mv subdir/a subdir/newa')
64
 
        self.assertMoved('subdir/a','subdir/newa')
 
67
        self.assertMoved('subdir/a', 'subdir/newa')
65
68
 
66
69
    def test_mv_unversioned(self):
67
70
        self.build_tree(['unversioned.txt'])
68
71
        self.run_bzr_error(
69
 
            ["^bzr: ERROR: Could not rename unversioned.txt => elsewhere."
70
 
             " .*unversioned.txt is not versioned\.$"],
 
72
            [b"^brz: ERROR: Could not rename unversioned.txt => elsewhere."
 
73
             b" .*unversioned.txt is not versioned\\.$"],
71
74
            'mv unversioned.txt elsewhere')
72
75
 
73
76
    def test_mv_nonexisting(self):
74
77
        self.run_bzr_error(
75
 
            ["^bzr: ERROR: Could not rename doesnotexist => somewhereelse."
76
 
             " .*doesnotexist is not versioned\.$"],
 
78
            [b"^brz: ERROR: Could not rename doesnotexist => somewhereelse."
 
79
             b" .*doesnotexist is not versioned\\.$"],
77
80
            'mv doesnotexist somewhereelse')
78
81
 
79
82
    def test_mv_unqualified(self):
80
 
        self.run_bzr_error(['^bzr: ERROR: missing file argument$'], 'mv')
 
83
        self.run_bzr_error([b'^brz: ERROR: missing file argument$'], 'mv')
81
84
 
82
85
    def test_mv_invalid(self):
83
86
        tree = self.make_branch_and_tree('.')
85
88
        tree.add(['test.txt'])
86
89
 
87
90
        self.run_bzr_error(
88
 
            ["^bzr: ERROR: Could not move to sub1: sub1 is not versioned\.$"],
 
91
            [b"^brz: ERROR: Could not move to sub1: sub1 is not versioned\\.$"],
89
92
            'mv test.txt sub1')
90
93
 
91
94
        self.run_bzr_error(
92
 
            ["^bzr: ERROR: Could not move test.txt => .*hello.txt: "
93
 
             "sub1 is not versioned\.$"],
 
95
            [b"^brz: ERROR: Could not move test.txt => .*hello.txt: "
 
96
             b"sub1 is not versioned\\.$"],
94
97
            'mv test.txt sub1/hello.txt')
95
98
 
96
99
    def test_mv_dirs(self):
99
102
        tree.add(['hello.txt', 'sub1'])
100
103
 
101
104
        self.run_bzr('mv sub1 sub2')
102
 
        self.assertMoved('sub1','sub2')
 
105
        self.assertMoved('sub1', 'sub2')
103
106
 
104
107
        self.run_bzr('mv hello.txt sub2')
105
 
        self.assertMoved('hello.txt','sub2/hello.txt')
 
108
        self.assertMoved('hello.txt', 'sub2/hello.txt')
106
109
 
107
110
        self.build_tree(['sub1/'])
108
111
        tree.add(['sub1'])
109
112
        self.run_bzr('mv sub2/hello.txt sub1')
110
 
        self.assertMoved('sub2/hello.txt','sub1/hello.txt')
 
113
        self.assertMoved('sub2/hello.txt', 'sub1/hello.txt')
111
114
 
112
115
        self.run_bzr('mv sub2 sub1')
113
 
        self.assertMoved('sub2','sub1/sub2')
 
116
        self.assertMoved('sub2', 'sub1/sub2')
114
117
 
115
118
    def test_mv_relative(self):
116
119
        self.build_tree(['sub1/', 'sub1/sub2/', 'sub1/hello.txt'])
117
120
        tree = self.make_branch_and_tree('.')
118
121
        tree.add(['sub1', 'sub1/sub2', 'sub1/hello.txt'])
119
122
 
120
 
        os.chdir('sub1/sub2')
121
 
        self.run_bzr('mv ../hello.txt .')
122
 
        self.failUnlessExists('./hello.txt')
 
123
        self.run_bzr('mv ../hello.txt .', working_dir='sub1/sub2')
 
124
        self.assertPathExists('sub1/sub2/hello.txt')
123
125
 
124
 
        os.chdir('..')
125
 
        self.run_bzr('mv sub2/hello.txt .')
126
 
        os.chdir('..')
127
 
        self.assertMoved('sub1/sub2/hello.txt','sub1/hello.txt')
 
126
        self.run_bzr('mv sub2/hello.txt .', working_dir='sub1')
 
127
        self.assertMoved('sub1/sub2/hello.txt', 'sub1/hello.txt')
128
128
 
129
129
    def test_mv_change_case_file(self):
130
130
        # test for bug #77740 (mv unable change filename case on Windows)
169
169
        self.build_tree(['foo/', 'bar'])
170
170
        tree.add(['foo', 'bar'])
171
171
        out, err = self.run_bzr('mv bar Foo', retcode=3)
172
 
        self.assertEquals('', out)
173
 
        self.assertEquals(
174
 
            'bzr: ERROR: Could not move to Foo: Foo is not versioned.\n',
 
172
        self.assertEqual(b'', out)
 
173
        self.assertEqual(
 
174
            b'brz: ERROR: Could not move to Foo: Foo is not versioned.\n',
175
175
            err)
176
176
 
177
177
    def test_mv_smoke_aliases(self):
184
184
        self.run_bzr('move a b')
185
185
        self.run_bzr('rename b a')
186
186
 
 
187
    def test_mv_no_root(self):
 
188
        tree = self.make_branch_and_tree('.')
 
189
        self.run_bzr_error(
 
190
            [b"brz: ERROR: can not move root of branch"],
 
191
            'mv . a')
 
192
 
187
193
    def test_mv_through_symlinks(self):
188
194
        self.requireFeature(SymlinkFeature)
189
195
        tree = self.make_branch_and_tree('.')
190
196
        self.build_tree(['a/', 'a/b'])
191
197
        os.symlink('a', 'c')
192
198
        os.symlink('.', 'd')
193
 
        tree.add(['a', 'a/b', 'c'], ['a-id', 'b-id', 'c-id'])
 
199
        tree.add(['a', 'a/b', 'c'], [b'a-id', b'b-id', b'c-id'])
194
200
        self.run_bzr('mv c/b b')
195
201
        tree = workingtree.WorkingTree.open('.')
196
 
        self.assertEqual('b-id', tree.path2id('b'))
 
202
        self.assertEqual(b'b-id', tree.path2id('b'))
197
203
 
198
204
    def test_mv_already_moved_file(self):
199
 
        """Test bzr mv original_file to moved_file.
 
205
        """Test brz mv original_file to moved_file.
200
206
 
201
207
        Tests if a file which has allready been moved by an external tool,
202
 
        is handled correctly by bzr mv.
 
208
        is handled correctly by brz mv.
203
209
        Setup: a is in the working tree, b does not exist.
204
 
        User does: mv a b; bzr mv a b
 
210
        User does: mv a b; brz mv a b
205
211
        """
206
212
        self.build_tree(['a'])
207
213
        tree = self.make_branch_and_tree('.')
209
215
 
210
216
        osutils.rename('a', 'b')
211
217
        self.run_bzr('mv a b')
212
 
        self.assertMoved('a','b')
 
218
        self.assertMoved('a', 'b')
213
219
 
214
220
    def test_mv_already_moved_file_to_versioned_target(self):
215
 
        """Test bzr mv existing_file to versioned_file.
 
221
        """Test brz mv existing_file to versioned_file.
216
222
 
217
223
        Tests if an attempt to move an existing versioned file
218
224
        to another versiond file will fail.
219
225
        Setup: a and b are in the working tree.
220
 
        User does: rm b; mv a b; bzr mv a b
 
226
        User does: rm b; mv a b; brz mv a b
221
227
        """
222
228
        self.build_tree(['a', 'b'])
223
229
        tree = self.make_branch_and_tree('.')
226
232
        os.remove('b')
227
233
        osutils.rename('a', 'b')
228
234
        self.run_bzr_error(
229
 
            ["^bzr: ERROR: Could not move a => b. b is already versioned\.$"],
 
235
            [b"^brz: ERROR: Could not move a => b. b is already versioned\\.$"],
230
236
            'mv a b')
231
237
        #check that nothing changed
232
 
        self.failIfExists('a')
233
 
        self.failUnlessExists('b')
 
238
        self.assertPathDoesNotExist('a')
 
239
        self.assertPathExists('b')
234
240
 
235
241
    def test_mv_already_moved_file_into_subdir(self):
236
 
        """Test bzr mv original_file to versioned_directory/file.
 
242
        """Test brz mv original_file to versioned_directory/file.
237
243
 
238
244
        Tests if a file which has already been moved into a versioned
239
 
        directory by an external tool, is handled correctly by bzr mv.
 
245
        directory by an external tool, is handled correctly by brz mv.
240
246
        Setup: a and sub/ are in the working tree.
241
 
        User does: mv a sub/a; bzr mv a sub/a
 
247
        User does: mv a sub/a; brz mv a sub/a
242
248
        """
243
249
        self.build_tree(['a', 'sub/'])
244
250
        tree = self.make_branch_and_tree('.')
246
252
 
247
253
        osutils.rename('a', 'sub/a')
248
254
        self.run_bzr('mv a sub/a')
249
 
        self.assertMoved('a','sub/a')
 
255
        self.assertMoved('a', 'sub/a')
250
256
 
251
257
    def test_mv_already_moved_file_into_unversioned_subdir(self):
252
 
        """Test bzr mv original_file to unversioned_directory/file.
 
258
        """Test brz mv original_file to unversioned_directory/file.
253
259
 
254
260
        Tests if an attempt to move an existing versioned file
255
261
        into an unversioned directory will fail.
256
262
        Setup: a is in the working tree, sub/ is not.
257
 
        User does: mv a sub/a; bzr mv a sub/a
 
263
        User does: mv a sub/a; brz mv a sub/a
258
264
        """
259
265
        self.build_tree(['a', 'sub/'])
260
266
        tree = self.make_branch_and_tree('.')
262
268
 
263
269
        osutils.rename('a', 'sub/a')
264
270
        self.run_bzr_error(
265
 
            ["^bzr: ERROR: Could not move a => a: sub is not versioned\.$"],
 
271
            [b"^brz: ERROR: Could not move a => a: sub is not versioned\\.$"],
266
272
            'mv a sub/a')
267
 
        self.failIfExists('a')
268
 
        self.failUnlessExists('sub/a')
 
273
        self.assertPathDoesNotExist('a')
 
274
        self.assertPathExists('sub/a')
269
275
 
270
276
    def test_mv_already_moved_files_into_subdir(self):
271
 
        """Test bzr mv original_files to versioned_directory.
 
277
        """Test brz mv original_files to versioned_directory.
272
278
 
273
279
        Tests if files which has already been moved into a versioned
274
 
        directory by an external tool, is handled correctly by bzr mv.
 
280
        directory by an external tool, is handled correctly by brz mv.
275
281
        Setup: a1, a2, sub are in the working tree.
276
 
        User does: mv a1 sub/.; bzr mv a1 a2 sub
 
282
        User does: mv a1 sub/.; brz mv a1 a2 sub
277
283
        """
278
284
        self.build_tree(['a1', 'a2', 'sub/'])
279
285
        tree = self.make_branch_and_tree('.')
281
287
 
282
288
        osutils.rename('a1', 'sub/a1')
283
289
        self.run_bzr('mv a1 a2 sub')
284
 
        self.assertMoved('a1','sub/a1')
285
 
        self.assertMoved('a2','sub/a2')
 
290
        self.assertMoved('a1', 'sub/a1')
 
291
        self.assertMoved('a2', 'sub/a2')
286
292
 
287
293
    def test_mv_already_moved_files_into_unversioned_subdir(self):
288
 
        """Test bzr mv original_file to unversioned_directory.
 
294
        """Test brz mv original_file to unversioned_directory.
289
295
 
290
296
        Tests if an attempt to move existing versioned file
291
297
        into an unversioned directory will fail.
292
298
        Setup: a1, a2 are in the working tree, sub is not.
293
 
        User does: mv a1 sub/.; bzr mv a1 a2 sub
 
299
        User does: mv a1 sub/.; brz mv a1 a2 sub
294
300
        """
295
301
        self.build_tree(['a1', 'a2', 'sub/'])
296
302
        tree = self.make_branch_and_tree('.')
298
304
 
299
305
        osutils.rename('a1', 'sub/a1')
300
306
        self.run_bzr_error(
301
 
            ["^bzr: ERROR: Could not move to sub. sub is not versioned\.$"],
 
307
            [b"^brz: ERROR: Could not move to sub. sub is not versioned\\.$"],
302
308
            'mv a1 a2 sub')
303
 
        self.failIfExists('a1')
304
 
        self.failUnlessExists('sub/a1')
305
 
        self.failUnlessExists('a2')
306
 
        self.failIfExists('sub/a2')
 
309
        self.assertPathDoesNotExist('a1')
 
310
        self.assertPathExists('sub/a1')
 
311
        self.assertPathExists('a2')
 
312
        self.assertPathDoesNotExist('sub/a2')
307
313
 
308
314
    def test_mv_already_moved_file_forcing_after(self):
309
 
        """Test bzr mv versioned_file to unversioned_file.
 
315
        """Test brz mv versioned_file to unversioned_file.
310
316
 
311
317
        Tests if an attempt to move an existing versioned file to an existing
312
318
        unversioned file will fail, informing the user to use the --after
313
319
        option to force this.
314
320
        Setup: a is in the working tree, b not versioned.
315
 
        User does: mv a b; touch a; bzr mv a b
 
321
        User does: mv a b; touch a; brz mv a b
316
322
        """
317
323
        self.build_tree(['a', 'b'])
318
324
        tree = self.make_branch_and_tree('.')
321
327
        osutils.rename('a', 'b')
322
328
        self.build_tree(['a']) #touch a
323
329
        self.run_bzr_error(
324
 
            ["^bzr: ERROR: Could not rename a => b because both files exist."
325
 
             " \(Use --after to tell bzr about a rename that has already"
326
 
             " happened\)$"],
 
330
            [b"^brz: ERROR: Could not rename a => b because both files exist."
 
331
             b" \\(Use --after to tell brz about a rename that has already"
 
332
             b" happened\\)$"],
327
333
            'mv a b')
328
 
        self.failUnlessExists('a')
329
 
        self.failUnlessExists('b')
 
334
        self.assertPathExists('a')
 
335
        self.assertPathExists('b')
330
336
 
331
337
    def test_mv_already_moved_file_using_after(self):
332
 
        """Test bzr mv --after versioned_file to unversioned_file.
 
338
        """Test brz mv --after versioned_file to unversioned_file.
333
339
 
334
340
        Tests if an existing versioned file can be forced to move to an
335
341
        existing unversioned file using the --after option. With the result
336
342
        that bazaar considers the unversioned_file to be moved from
337
343
        versioned_file and versioned_file will become unversioned.
338
344
        Setup: a is in the working tree and b exists.
339
 
        User does: mv a b; touch a; bzr mv a b --after
 
345
        User does: mv a b; touch a; brz mv a b --after
340
346
        Resulting in a => b and a is unknown.
341
347
        """
342
348
        self.build_tree(['a', 'b'])
346
352
        self.build_tree(['a']) #touch a
347
353
 
348
354
        self.run_bzr('mv a b --after')
349
 
        self.failUnlessExists('a')
 
355
        self.assertPathExists('a')
350
356
        self.assertNotInWorkingTree('a')#a should be unknown now.
351
 
        self.failUnlessExists('b')
 
357
        self.assertPathExists('b')
352
358
        self.assertInWorkingTree('b')
353
359
 
354
360
    def test_mv_already_moved_files_forcing_after(self):
355
 
        """Test bzr mv versioned_files to directory/unversioned_file.
 
361
        """Test brz mv versioned_files to directory/unversioned_file.
356
362
 
357
363
        Tests if an attempt to move an existing versioned file to an existing
358
364
        unversioned file in some other directory will fail, informing the user
360
366
 
361
367
        Setup: a1, a2, sub are versioned and in the working tree,
362
368
               sub/a1, sub/a2 are in working tree.
363
 
        User does: mv a* sub; touch a1; touch a2; bzr mv a1 a2 sub
 
369
        User does: mv a* sub; touch a1; touch a2; brz mv a1 a2 sub
364
370
        """
365
371
        self.build_tree(['a1', 'a2', 'sub/', 'sub/a1', 'sub/a2'])
366
372
        tree = self.make_branch_and_tree('.')
371
377
        self.build_tree(['a2']) #touch a2
372
378
 
373
379
        self.run_bzr_error(
374
 
            ["^bzr: ERROR: Could not rename a1 => sub/a1 because both files"
375
 
             " exist. \(Use --after to tell bzr about a rename that has already"
376
 
             " happened\)$"],
 
380
            [b"^brz: ERROR: Could not rename a1 => sub/a1 because both files"
 
381
             b" exist. \\(Use --after to tell brz about a rename that has already"
 
382
             b" happened\\)$"],
377
383
            'mv a1 a2 sub')
378
 
        self.failUnlessExists('a1')
379
 
        self.failUnlessExists('a2')
380
 
        self.failUnlessExists('sub/a1')
381
 
        self.failUnlessExists('sub/a2')
 
384
        self.assertPathExists('a1')
 
385
        self.assertPathExists('a2')
 
386
        self.assertPathExists('sub/a1')
 
387
        self.assertPathExists('sub/a2')
382
388
 
383
389
    def test_mv_already_moved_files_using_after(self):
384
 
        """Test bzr mv --after versioned_file to directory/unversioned_file.
 
390
        """Test brz mv --after versioned_file to directory/unversioned_file.
385
391
 
386
392
        Tests if an existing versioned file can be forced to move to an
387
393
        existing unversioned file in some other directory using the --after
391
397
 
392
398
        Setup: a1, a2, sub are versioned and in the working tree,
393
399
               sub/a1, sub/a2 are in working tree.
394
 
        User does: mv a* sub; touch a1; touch a2; bzr mv a1 a2 sub --after
 
400
        User does: mv a* sub; touch a1; touch a2; brz mv a1 a2 sub --after
395
401
        """
396
402
        self.build_tree(['a1', 'a2', 'sub/', 'sub/a1', 'sub/a2'])
397
403
        tree = self.make_branch_and_tree('.')
402
408
        self.build_tree(['a2']) #touch a2
403
409
 
404
410
        self.run_bzr('mv a1 a2 sub --after')
405
 
        self.failUnlessExists('a1')
406
 
        self.failUnlessExists('a2')
407
 
        self.failUnlessExists('sub/a1')
408
 
        self.failUnlessExists('sub/a2')
 
411
        self.assertPathExists('a1')
 
412
        self.assertPathExists('a2')
 
413
        self.assertPathExists('sub/a1')
 
414
        self.assertPathExists('sub/a2')
409
415
        self.assertInWorkingTree('sub/a1')
410
416
        self.assertInWorkingTree('sub/a2')
411
417
 
412
418
    def test_mv_already_moved_directory(self):
413
 
        """Use `bzr mv a b` to mark a directory as renamed.
 
419
        """Use `brz mv a b` to mark a directory as renamed.
414
420
 
415
421
        https://bugs.launchpad.net/bzr/+bug/107967/
416
422
        """
421
427
        osutils.rename('c', 'd')
422
428
        # mv a b should work just like it does for already renamed files
423
429
        self.run_bzr('mv a b')
424
 
        self.failIfExists('a')
 
430
        self.assertPathDoesNotExist('a')
425
431
        self.assertNotInWorkingTree('a')
426
 
        self.failUnlessExists('b')
 
432
        self.assertPathExists('b')
427
433
        self.assertInWorkingTree('b')
428
434
        # and --after should work, too (technically it's ignored)
429
435
        self.run_bzr('mv --after c d')
430
 
        self.failIfExists('c')
 
436
        self.assertPathDoesNotExist('c')
431
437
        self.assertNotInWorkingTree('c')
432
 
        self.failUnlessExists('d')
 
438
        self.assertPathExists('d')
433
439
        self.assertInWorkingTree('d')
434
440
 
435
441
    def make_abcd_tree(self):
444
450
    def test_mv_auto(self):
445
451
        self.make_abcd_tree()
446
452
        out, err = self.run_bzr('mv --auto', working_dir='tree')
447
 
        self.assertEqual(out, '')
448
 
        self.assertEqual(err, 'a => b\nc => d\n')
 
453
        self.assertEqual(out, b'')
 
454
        self.assertEqual(err, b'a => b\nc => d\n')
449
455
        tree = workingtree.WorkingTree.open('tree')
450
 
        self.assertIsNot(None, tree.path2id('b'))
451
 
        self.assertIsNot(None, tree.path2id('d'))
 
456
        self.assertTrue(tree.is_versioned('b'))
 
457
        self.assertTrue(tree.is_versioned('d'))
452
458
 
453
459
    def test_mv_auto_one_path(self):
454
460
        self.make_abcd_tree()
455
461
        out, err = self.run_bzr('mv --auto tree')
456
 
        self.assertEqual(out, '')
457
 
        self.assertEqual(err, 'a => b\nc => d\n')
 
462
        self.assertEqual(out, b'')
 
463
        self.assertEqual(err, b'a => b\nc => d\n')
458
464
        tree = workingtree.WorkingTree.open('tree')
459
 
        self.assertIsNot(None, tree.path2id('b'))
460
 
        self.assertIsNot(None, tree.path2id('d'))
 
465
        self.assertTrue(tree.is_versioned('b'))
 
466
        self.assertTrue(tree.is_versioned('d'))
461
467
 
462
468
    def test_mv_auto_two_paths(self):
463
469
        self.make_abcd_tree()
464
470
        out, err = self.run_bzr('mv --auto tree tree2', retcode=3)
465
 
        self.assertEqual('bzr: ERROR: Only one path may be specified to'
466
 
                         ' --auto.\n', err)
 
471
        self.assertEqual(b'brz: ERROR: Only one path may be specified to'
 
472
                         b' --auto.\n', err)
467
473
 
468
474
    def test_mv_auto_dry_run(self):
469
475
        self.make_abcd_tree()
470
476
        out, err = self.run_bzr('mv --auto --dry-run', working_dir='tree')
471
 
        self.assertEqual(out, '')
472
 
        self.assertEqual(err, 'a => b\nc => d\n')
 
477
        self.assertEqual(out, b'')
 
478
        self.assertEqual(err, b'a => b\nc => d\n')
473
479
        tree = workingtree.WorkingTree.open('tree')
474
 
        self.assertIsNot(None, tree.path2id('a'))
475
 
        self.assertIsNot(None, tree.path2id('c'))
 
480
        self.assertTrue(tree.is_versioned('a'))
 
481
        self.assertTrue(tree.is_versioned('c'))
476
482
 
477
483
    def test_mv_no_auto_dry_run(self):
478
484
        self.make_abcd_tree()
479
485
        out, err = self.run_bzr('mv c d --dry-run',
480
486
                                working_dir='tree', retcode=3)
481
 
        self.assertEqual('bzr: ERROR: --dry-run requires --auto.\n', err)
 
487
        self.assertEqual(b'brz: ERROR: --dry-run requires --auto.\n', err)
482
488
 
483
489
    def test_mv_auto_after(self):
484
490
        self.make_abcd_tree()
485
491
        out, err = self.run_bzr('mv --auto --after', working_dir='tree',
486
492
                                retcode=3)
487
 
        self.assertEqual('bzr: ERROR: --after cannot be specified with'
488
 
                         ' --auto.\n', err)
 
493
        self.assertEqual(b'brz: ERROR: --after cannot be specified with'
 
494
                         b' --auto.\n', err)
489
495
 
490
496
    def test_mv_quiet(self):
491
497
        tree = self.make_branch_and_tree('.')
492
498
        self.build_tree(['aaa'])
493
499
        tree.add(['aaa'])
494
500
        out, err = self.run_bzr('mv --quiet aaa bbb')
495
 
        self.assertEqual(out, '')
496
 
        self.assertEqual(err, '')
 
501
        self.assertEqual(out, b'')
 
502
        self.assertEqual(err, b'')
497
503
 
498
504
    def test_mv_readonly_lightweight_checkout(self):
499
505
        branch = self.make_branch('foo')
500
 
        branch = bzrlib.branch.Branch.open(self.get_readonly_url('foo'))
 
506
        branch = breezy.branch.Branch.open(self.get_readonly_url('foo'))
501
507
        tree = branch.create_checkout('tree', lightweight=True)
502
508
        self.build_tree(['tree/path'])
503
509
        tree.add('path')
504
510
        # If this fails, the tree is trying to acquire a branch lock, which it
505
511
        # shouldn't.
506
512
        self.run_bzr(['mv', 'tree/path', 'tree/path2'])
 
513
 
 
514
    def test_mv_unversioned_non_ascii(self):
 
515
        """Clear error on mv of an unversioned non-ascii file, see lp:707954"""
 
516
        self.requireFeature(UnicodeFilenameFeature)
 
517
        tree = self.make_branch_and_tree(".")
 
518
        self.build_tree([u"\xA7"])
 
519
        out, err = self.run_bzr_error([b"Could not rename", b"not versioned"],
 
520
            ["mv", u"\xA7", "b"])
 
521
 
 
522
    def test_mv_removed_non_ascii(self):
 
523
        """Clear error on mv of a removed non-ascii file, see lp:898541"""
 
524
        self.requireFeature(UnicodeFilenameFeature)
 
525
        tree = self.make_branch_and_tree(".")
 
526
        self.build_tree([u"\xA7"])
 
527
        tree.add([u"\xA7"])
 
528
        tree.commit(u"Adding \xA7")
 
529
        os.remove(u"\xA7")
 
530
        out, err = self.run_bzr_error([b"Could not rename", b"not exist"],
 
531
            ["mv", u"\xA7", "b"])