/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_status.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from ...revisionspec import RevisionSpec
41
41
from ...sixish import (
42
42
    BytesIO,
43
 
    StringIO,
44
 
    PY3,
45
43
    )
46
44
from ...status import show_tree_status
47
45
from .. import TestCaseWithTransport, TestSkipped
55
53
        # As TestCase.setUp clears all hooks, we install this default
56
54
        # post_status hook handler for the test.
57
55
        status.hooks.install_named_hook('post_status',
58
 
                                        status._show_shelve_summary,
59
 
                                        'brz status')
 
56
            status._show_shelve_summary,
 
57
            'brz status')
60
58
 
61
59
    def assertStatus(self, expected_lines, working_tree, specific_files=None,
62
 
                     revision=None, short=False, pending=True, verbose=False):
 
60
        revision=None, short=False, pending=True, verbose=False):
63
61
        """Run status in working_tree and look for output.
64
62
 
65
63
        :param expected_lines: The lines to look for.
66
64
        :param working_tree: The tree to run status in.
67
65
        """
68
66
        output_string = self.status_string(working_tree, specific_files, revision, short,
69
 
                                           pending, verbose)
 
67
                pending, verbose)
70
68
        self.assertEqual(expected_lines, output_string.splitlines(True))
71
69
 
72
70
    def status_string(self, wt, specific_files=None, revision=None,
73
 
                      short=False, pending=True, verbose=False):
 
71
        short=False, pending=True, verbose=False):
74
72
        uio = self.make_utf8_encoded_stringio()
75
73
        show_tree_status(wt, specific_files=specific_files, to_file=uio,
76
 
                         revision=revision, short=short, show_pending=pending,
77
 
                         verbose=verbose)
 
74
                revision=revision, short=short, show_pending=pending,
 
75
                verbose=verbose)
78
76
        return uio.getvalue().decode('utf-8')
79
77
 
80
78
    def test_branch_status(self):
89
87
 
90
88
        self.build_tree(['hello.c', 'bye.c'])
91
89
        self.assertStatus([
92
 
            'unknown:\n',
93
 
            '  bye.c\n',
94
 
            '  hello.c\n',
 
90
                'unknown:\n',
 
91
                '  bye.c\n',
 
92
                '  hello.c\n',
95
93
            ],
96
94
            wt)
97
95
        self.assertStatus([
98
 
            '?   bye.c\n',
99
 
            '?   hello.c\n',
 
96
                '?   bye.c\n',
 
97
                '?   hello.c\n',
100
98
            ],
101
99
            wt, short=True)
102
100
 
103
101
        # add a commit to allow showing pending merges.
104
102
        wt.commit('create a parent to allow testing merge output')
105
103
 
106
 
        wt.add_parent_tree_id(b'pending@pending-0-0')
 
104
        wt.add_parent_tree_id('pending@pending-0-0')
107
105
        self.assertStatus([
108
 
            'unknown:\n',
109
 
            '  bye.c\n',
110
 
            '  hello.c\n',
111
 
            'pending merge tips: (use -v to see all merge revisions)\n',
112
 
            '  (ghost) pending@pending-0-0\n',
 
106
                'unknown:\n',
 
107
                '  bye.c\n',
 
108
                '  hello.c\n',
 
109
                'pending merge tips: (use -v to see all merge revisions)\n',
 
110
                '  (ghost) pending@pending-0-0\n',
113
111
            ],
114
112
            wt)
115
113
        self.assertStatus([
116
 
            'unknown:\n',
117
 
            '  bye.c\n',
118
 
            '  hello.c\n',
119
 
            'pending merges:\n',
120
 
            '  (ghost) pending@pending-0-0\n',
 
114
                'unknown:\n',
 
115
                '  bye.c\n',
 
116
                '  hello.c\n',
 
117
                'pending merges:\n',
 
118
                '  (ghost) pending@pending-0-0\n',
121
119
            ],
122
120
            wt, verbose=True)
123
121
        self.assertStatus([
124
 
            '?   bye.c\n',
125
 
            '?   hello.c\n',
126
 
            'P   (ghost) pending@pending-0-0\n',
 
122
                '?   bye.c\n',
 
123
                '?   hello.c\n',
 
124
                'P   (ghost) pending@pending-0-0\n',
127
125
            ],
128
126
            wt, short=True)
129
127
        self.assertStatus([
130
 
            'unknown:\n',
131
 
            '  bye.c\n',
132
 
            '  hello.c\n',
 
128
                'unknown:\n',
 
129
                '  bye.c\n',
 
130
                '  hello.c\n',
133
131
            ],
134
132
            wt, pending=False)
135
133
        self.assertStatus([
136
 
            '?   bye.c\n',
137
 
            '?   hello.c\n',
 
134
                '?   bye.c\n',
 
135
                '?   hello.c\n',
138
136
            ],
139
137
            wt, short=True, pending=False)
140
138
 
149
147
 
150
148
        revs = [RevisionSpec.from_string('0')]
151
149
        self.assertStatus([
152
 
            'added:\n',
153
 
            '  bye.c\n',
154
 
            '  hello.c\n'
 
150
                'added:\n',
 
151
                '  bye.c\n',
 
152
                '  hello.c\n'
155
153
            ],
156
154
            wt,
157
155
            revision=revs)
162
160
 
163
161
        revs.append(RevisionSpec.from_string('1'))
164
162
        self.assertStatus([
165
 
            'added:\n',
166
 
            '  bye.c\n',
167
 
            '  hello.c\n',
 
163
                'added:\n',
 
164
                '  bye.c\n',
 
165
                '  hello.c\n',
168
166
            ],
169
167
            wt,
170
168
            revision=revs)
185
183
        self.assertEndsWith(message, "Empty commit 2\n")
186
184
        wt2.commit("merged")
187
185
        # must be long to make sure we see elipsis at the end
188
 
        wt.commit("Empty commit 3 "
189
 
                  + "blah blah blah blah " * 100)
 
186
        wt.commit("Empty commit 3 " +
 
187
                   "blah blah blah blah " * 100)
190
188
        wt2.merge_from_branch(wt.branch)
191
189
        message = self.status_string(wt2, verbose=True)
192
190
        self.assertStartsWith(message, "pending merges:\n")
200
198
        wt.commit('commit .bzrignore')
201
199
        self.build_tree(['foo.c', 'foo.c~'])
202
200
        self.assertStatus([
203
 
            'unknown:\n',
204
 
            '  foo.c\n',
205
 
            ],
206
 
            wt)
 
201
                'unknown:\n',
 
202
                '  foo.c\n',
 
203
                ],
 
204
                wt)
207
205
        self.assertStatus([
208
 
            '?   foo.c\n',
209
 
            ],
210
 
            wt, short=True)
 
206
                '?   foo.c\n',
 
207
                ],
 
208
                wt, short=True)
211
209
 
212
210
    def test_tree_status_specific_files(self):
213
211
        """Tests branch status with given specific files"""
224
222
        unlink('missing.c')
225
223
 
226
224
        self.assertStatus([
227
 
            'missing:\n',
228
 
            '  missing.c\n',
229
 
            'unknown:\n',
230
 
            '  bye.c\n',
231
 
            '  dir2/\n',
232
 
            '  directory/hello.c\n'
233
 
            ],
234
 
            wt)
 
225
                'missing:\n',
 
226
                '  missing.c\n',
 
227
                'unknown:\n',
 
228
                '  bye.c\n',
 
229
                '  dir2/\n',
 
230
                '  directory/hello.c\n'
 
231
                ],
 
232
                wt)
235
233
 
236
234
        self.assertStatus([
237
 
            '?   bye.c\n',
238
 
            '?   dir2/\n',
239
 
            '?   directory/hello.c\n',
240
 
            '+!  missing.c\n',
241
 
            ],
242
 
            wt, short=True)
 
235
                '?   bye.c\n',
 
236
                '?   dir2/\n',
 
237
                '+!  missing.c\n',
 
238
                '?   directory/hello.c\n'
 
239
                ],
 
240
                wt, short=True)
243
241
 
244
 
        tof = StringIO()
 
242
        tof = BytesIO()
245
243
        self.assertRaises(errors.PathsDoNotExist,
246
244
                          show_tree_status,
247
245
                          wt, specific_files=['bye.c', 'test.c', 'absent.c'],
248
246
                          to_file=tof)
249
247
 
250
 
        tof = StringIO()
 
248
        tof = BytesIO()
251
249
        show_tree_status(wt, specific_files=['directory'], to_file=tof)
252
250
        tof.seek(0)
253
251
        self.assertEqual(tof.readlines(),
254
 
                         ['unknown:\n',
255
 
                          '  directory/hello.c\n'
256
 
                          ])
257
 
        tof = StringIO()
 
252
                          ['unknown:\n',
 
253
                           '  directory/hello.c\n'
 
254
                           ])
 
255
        tof = BytesIO()
258
256
        show_tree_status(wt, specific_files=['directory'], to_file=tof,
259
257
                         short=True)
260
258
        tof.seek(0)
261
259
        self.assertEqual(tof.readlines(), ['?   directory/hello.c\n'])
262
260
 
263
 
        tof = StringIO()
 
261
        tof = BytesIO()
264
262
        show_tree_status(wt, specific_files=['dir2'], to_file=tof)
265
263
        tof.seek(0)
266
264
        self.assertEqual(tof.readlines(),
267
 
                         ['unknown:\n',
268
 
                          '  dir2/\n'
269
 
                          ])
270
 
        tof = StringIO()
 
265
                          ['unknown:\n',
 
266
                           '  dir2/\n'
 
267
                           ])
 
268
        tof = BytesIO()
271
269
        show_tree_status(wt, specific_files=['dir2'], to_file=tof, short=True)
272
270
        tof.seek(0)
273
271
        self.assertEqual(tof.readlines(), ['?   dir2/\n'])
274
272
 
275
 
        tof = StringIO()
 
273
        tof = BytesIO()
276
274
        revs = [RevisionSpec.from_string('0'), RevisionSpec.from_string('1')]
277
275
        show_tree_status(wt, specific_files=['test.c'], to_file=tof,
278
276
                         short=True, revision=revs)
279
277
        tof.seek(0)
280
278
        self.assertEqual(tof.readlines(), ['+N  test.c\n'])
281
279
 
282
 
        tof = StringIO()
 
280
        tof = BytesIO()
283
281
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
284
282
        tof.seek(0)
285
283
        self.assertEqual(tof.readlines(),
286
 
                         ['missing:\n',
287
 
                          '  missing.c\n'])
 
284
                          ['missing:\n',
 
285
                           '  missing.c\n'])
288
286
 
289
 
        tof = StringIO()
 
287
        tof = BytesIO()
290
288
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
291
289
                         short=True)
292
290
        tof.seek(0)
293
291
        self.assertEqual(tof.readlines(),
294
 
                         ['+!  missing.c\n'])
 
292
                          ['+!  missing.c\n'])
295
293
 
296
294
    def test_specific_files_conflicts(self):
297
295
        tree = self.make_branch_and_tree('.')
302
300
            [conflicts.ContentsConflict('foo')]))
303
301
        tof = BytesIO()
304
302
        show_tree_status(tree, specific_files=['dir2'], to_file=tof)
305
 
        self.assertEqualDiff(b'', tof.getvalue())
 
303
        self.assertEqualDiff('', tof.getvalue())
306
304
        tree.set_conflicts(conflicts.ConflictList(
307
305
            [conflicts.ContentsConflict('dir2')]))
308
 
        tof = StringIO()
 
306
        tof = BytesIO()
309
307
        show_tree_status(tree, specific_files=['dir2'], to_file=tof)
310
308
        self.assertEqualDiff('conflicts:\n  Contents conflict in dir2\n',
311
309
                             tof.getvalue())
312
310
 
313
311
        tree.set_conflicts(conflicts.ConflictList(
314
312
            [conflicts.ContentsConflict('dir2/file1')]))
315
 
        tof = StringIO()
 
313
        tof = BytesIO()
316
314
        show_tree_status(tree, specific_files=['dir2'], to_file=tof)
317
315
        self.assertEqualDiff('conflicts:\n  Contents conflict in dir2/file1\n',
318
316
                             tof.getvalue())
327
325
        wt.add('FILE_D')
328
326
        wt.add('FILE_E')
329
327
        wt.commit('Create five empty files.')
330
 
        with open('FILE_B', 'w') as f:
331
 
            f.write('Modification to file FILE_B.')
332
 
        with open('FILE_C', 'w') as f:
333
 
            f.write('Modification to file FILE_C.')
 
328
        with open('FILE_B', 'w') as f: f.write('Modification to file FILE_B.')
 
329
        with open('FILE_C', 'w') as f: f.write('Modification to file FILE_C.')
334
330
        unlink('FILE_E')  # FILE_E will be versioned but missing
335
 
        with open('FILE_Q', 'w') as f:
336
 
            f.write('FILE_Q is added but not committed.')
 
331
        with open('FILE_Q', 'w') as f: f.write('FILE_Q is added but not committed.')
337
332
        wt.add('FILE_Q')  # FILE_Q will be added but not committed
338
333
        open('UNVERSIONED_BUT_EXISTING', 'w')
339
334
        return wt
368
363
 
369
364
        # brz st [--short] NONEXISTENT '
370
365
        expected = [
371
 
            'nonexistent:\n',
372
 
            '  NONEXISTENT\n',
373
 
            ]
 
366
          'nonexistent:\n',
 
367
          '  NONEXISTENT\n',
 
368
          ]
374
369
        out, err = self.run_bzr('status NONEXISTENT', retcode=3)
375
370
        self.assertEqual(expected, out.splitlines(True))
376
371
        self.assertContainsRe(err,
377
372
                              r'.*ERROR: Path\(s\) do not exist: '
378
373
                              'NONEXISTENT.*')
379
374
        expected = [
380
 
            'X:   NONEXISTENT\n',
381
 
            ]
 
375
          'X:   NONEXISTENT\n',
 
376
          ]
382
377
        out, err = self.run_bzr('status --short NONEXISTENT', retcode=3)
383
378
        self.assertContainsRe(err,
384
379
                              r'.*ERROR: Path\(s\) do not exist: '
388
383
        # brz st [--short] NONEXISTENT ...others..
389
384
        wt = self._prepare_nonexistent()
390
385
        expected = [
391
 
            'removed:\n',
392
 
            '  FILE_E\n',
393
 
            'modified:\n',
394
 
            '  FILE_B\n',
395
 
            '  FILE_C\n',
396
 
            'nonexistent:\n',
397
 
            '  NONEXISTENT\n',
398
 
            ]
 
386
          'removed:\n',
 
387
          '  FILE_E\n',
 
388
          'modified:\n',
 
389
          '  FILE_B\n',
 
390
          '  FILE_C\n',
 
391
          'nonexistent:\n',
 
392
          '  NONEXISTENT\n',
 
393
          ]
399
394
        out, err = self.run_bzr('status NONEXISTENT '
400
395
                                'FILE_A FILE_B FILE_C FILE_D FILE_E',
401
396
                                retcode=3)
404
399
                              r'.*ERROR: Path\(s\) do not exist: '
405
400
                              'NONEXISTENT.*')
406
401
        expected = [
407
 
            ' M  FILE_B\n',
408
 
            ' M  FILE_C\n',
409
 
            ' D  FILE_E\n',
410
 
            'X   NONEXISTENT\n',
411
 
            ]
 
402
          ' D  FILE_E\n',
 
403
          ' M  FILE_C\n',
 
404
          ' M  FILE_B\n',
 
405
          'X   NONEXISTENT\n',
 
406
          ]
412
407
        out, err = self.run_bzr('status --short NONEXISTENT '
413
408
                                'FILE_A FILE_B FILE_C FILE_D FILE_E',
414
409
                                retcode=3)
421
416
        # brz st [--short] NONEXISTENT ... ANOTHER_NONEXISTENT ...
422
417
        wt = self._prepare_nonexistent()
423
418
        expected = [
424
 
            'removed:\n',
425
 
            '  FILE_E\n',
426
 
            'modified:\n',
427
 
            '  FILE_B\n',
428
 
            '  FILE_C\n',
429
 
            'nonexistent:\n',
430
 
            '  ANOTHER_NONEXISTENT\n',
431
 
            '  NONEXISTENT\n',
432
 
            ]
 
419
          'removed:\n',
 
420
          '  FILE_E\n',
 
421
          'modified:\n',
 
422
          '  FILE_B\n',
 
423
          '  FILE_C\n',
 
424
          'nonexistent:\n',
 
425
          '  ANOTHER_NONEXISTENT\n',
 
426
          '  NONEXISTENT\n',
 
427
          ]
433
428
        out, err = self.run_bzr('status NONEXISTENT '
434
429
                                'FILE_A FILE_B ANOTHER_NONEXISTENT '
435
430
                                'FILE_C FILE_D FILE_E', retcode=3)
438
433
                              r'.*ERROR: Path\(s\) do not exist: '
439
434
                              'ANOTHER_NONEXISTENT NONEXISTENT.*')
440
435
        expected = [
441
 
            ' M  FILE_B\n',
442
 
            ' M  FILE_C\n',
443
 
            ' D  FILE_E\n',
444
 
            'X   ANOTHER_NONEXISTENT\n',
445
 
            'X   NONEXISTENT\n',
446
 
            ]
 
436
          ' D  FILE_E\n',
 
437
          ' M  FILE_C\n',
 
438
          ' M  FILE_B\n',
 
439
          'X   ANOTHER_NONEXISTENT\n',
 
440
          'X   NONEXISTENT\n',
 
441
          ]
447
442
        out, err = self.run_bzr('status --short NONEXISTENT '
448
443
                                'FILE_A FILE_B ANOTHER_NONEXISTENT '
449
444
                                'FILE_C FILE_D FILE_E', retcode=3)
456
451
        # brz st [--short] NONEXISTENT A B UNVERSIONED_BUT_EXISTING C D E Q
457
452
        wt = self._prepare_nonexistent()
458
453
        expected = [
459
 
            'removed:\n',
460
 
            '  FILE_E\n',
461
 
            'added:\n',
462
 
            '  FILE_Q\n',
463
 
            'modified:\n',
464
 
            '  FILE_B\n',
465
 
            '  FILE_C\n',
466
 
            'unknown:\n',
467
 
            '  UNVERSIONED_BUT_EXISTING\n',
468
 
            'nonexistent:\n',
469
 
            '  NONEXISTENT\n',
470
 
            ]
 
454
          'removed:\n',
 
455
          '  FILE_E\n',
 
456
          'added:\n',
 
457
          '  FILE_Q\n',
 
458
          'modified:\n',
 
459
          '  FILE_B\n',
 
460
          '  FILE_C\n',
 
461
          'unknown:\n',
 
462
          '  UNVERSIONED_BUT_EXISTING\n',
 
463
          'nonexistent:\n',
 
464
          '  NONEXISTENT\n',
 
465
          ]
471
466
        out, err = self.run_bzr('status NONEXISTENT '
472
467
                                'FILE_A FILE_B UNVERSIONED_BUT_EXISTING '
473
468
                                'FILE_C FILE_D FILE_E FILE_Q', retcode=3)
476
471
                              r'.*ERROR: Path\(s\) do not exist: '
477
472
                              'NONEXISTENT.*')
478
473
        expected = sorted([
479
 
            '+N  FILE_Q\n',
480
 
            '?   UNVERSIONED_BUT_EXISTING\n',
481
 
            ' D  FILE_E\n',
482
 
            ' M  FILE_C\n',
483
 
            ' M  FILE_B\n',
484
 
            'X   NONEXISTENT\n',
485
 
            ])
 
474
          '+N  FILE_Q\n',
 
475
          '?   UNVERSIONED_BUT_EXISTING\n',
 
476
          ' D  FILE_E\n',
 
477
          ' M  FILE_C\n',
 
478
          ' M  FILE_B\n',
 
479
          'X   NONEXISTENT\n',
 
480
          ])
486
481
        out, err = self.run_bzr('status --short NONEXISTENT '
487
482
                                'FILE_A FILE_B UNVERSIONED_BUT_EXISTING '
488
483
                                'FILE_C FILE_D FILE_E FILE_Q', retcode=3)
497
492
        """Simulate status of out-of-date tree after remote push"""
498
493
        tree = self.make_branch_and_tree('.')
499
494
        self.build_tree_contents([('a', b'foo\n')])
500
 
        with tree.lock_write():
 
495
        tree.lock_write()
 
496
        try:
501
497
            tree.add(['a'])
502
498
            tree.commit('add test file')
503
499
            # simulate what happens after a remote push
504
 
            tree.set_last_revision(b"0")
 
500
            tree.set_last_revision("0")
 
501
        finally:
 
502
            # before run another commands we should unlock tree
 
503
            tree.unlock()
505
504
        out, err = self.run_bzr('status')
506
505
        self.assertEqual("working tree is out of date, run 'brz update'\n",
507
506
                         err)
517
516
        result = self.run_bzr('status')[0]
518
517
        self.assertContainsRe(result, "unknown:\n  test1.c\n")
519
518
        short_result = self.run_bzr('status --short')[0]
520
 
        self.assertContainsRe(short_result, "\\?   test1.c\n")
 
519
        self.assertContainsRe(short_result, "\?   test1.c\n")
521
520
 
522
521
        result = self.run_bzr('status test1.c')[0]
523
522
        self.assertContainsRe(result, "unknown:\n  test1.c\n")
524
523
        short_result = self.run_bzr('status --short test1.c')[0]
525
 
        self.assertContainsRe(short_result, "\\?   test1.c\n")
 
524
        self.assertContainsRe(short_result, "\?   test1.c\n")
526
525
 
527
526
        result = self.run_bzr('status test1.c~')[0]
528
527
        self.assertContainsRe(result, "ignored:\n  test1.c~\n")
535
534
        self.assertContainsRe(short_result, "I   test1.c~\nI   test2.c~\n")
536
535
 
537
536
        result = self.run_bzr('status test1.c test1.c~ test2.c~')[0]
538
 
        self.assertContainsRe(
539
 
            result, "unknown:\n  test1.c\nignored:\n  test1.c~\n  test2.c~\n")
540
 
        short_result = self.run_bzr(
541
 
            'status --short test1.c test1.c~ test2.c~')[0]
542
 
        self.assertContainsRe(
543
 
            short_result, "\\?   test1.c\nI   test1.c~\nI   test2.c~\n")
 
537
        self.assertContainsRe(result, "unknown:\n  test1.c\nignored:\n  test1.c~\n  test2.c~\n")
 
538
        short_result = self.run_bzr('status --short test1.c test1.c~ test2.c~')[0]
 
539
        self.assertContainsRe(short_result, "\?   test1.c\nI   test1.c~\nI   test2.c~\n")
544
540
 
545
541
    def test_status_write_lock(self):
546
542
        """Test that status works without fetching history and
567
563
        self.build_tree(['bye.c'])
568
564
        wt.add('bye.c')
569
565
        self.assertStatus([
570
 
            'added:\n',
571
 
            '  bye.c\n',
572
 
            '1 shelf exists. See "brz shelve --list" for details.\n',
 
566
                'added:\n',
 
567
                '  bye.c\n',
 
568
                '1 shelf exists. See "brz shelve --list" for details.\n',
573
569
            ],
574
570
            wt)
575
571
        self.run_bzr(['shelve', '--all', '-m', 'bar'])
577
573
        wt.add('eggs.c')
578
574
        wt.add('spam.c')
579
575
        self.assertStatus([
580
 
            'added:\n',
581
 
            '  eggs.c\n',
582
 
            '  spam.c\n',
583
 
            '2 shelves exist. See "brz shelve --list" for details.\n',
 
576
                'added:\n',
 
577
                '  eggs.c\n',
 
578
                '  spam.c\n',
 
579
                '2 shelves exist. See "brz shelve --list" for details.\n',
584
580
            ],
585
581
            wt)
586
582
        self.assertStatus([
587
 
            'added:\n',
588
 
            '  spam.c\n',
 
583
                'added:\n',
 
584
                '  spam.c\n',
589
585
            ],
590
586
            wt,
591
587
            specific_files=['spam.c'])
627
623
 
628
624
        self.build_tree(['world.txt'])
629
625
        result = self.run_bzr("status -r 0")[0]
630
 
        self.assertContainsRe(result, "added:\n  hello.txt\n"
 
626
        self.assertContainsRe(result, "added:\n  hello.txt\n" \
631
627
                                      "unknown:\n  world.txt\n")
632
628
        result2 = self.run_bzr("status -r 0..")[0]
633
629
        self.assertEqual(result2, result)
649
645
 
650
646
        self.build_tree(['world.txt'])
651
647
        result = self.run_bzr("status -S -r 0")[0]
652
 
        self.assertContainsRe(result, "[+]N  hello.txt\n"
 
648
        self.assertContainsRe(result, "[+]N  hello.txt\n" \
653
649
                                      "[?]   world.txt\n")
654
650
        result2 = self.run_bzr("status -S -r 0..")[0]
655
651
        self.assertEqual(result2, result)
713
709
        tree.commit('added file')
714
710
        unlink('file')
715
711
        self.build_tree(['file/'])
716
 
        self.assertStatusContains(
717
 
            'kind changed:\n  file \\(file => directory\\)')
 
712
        self.assertStatusContains('kind changed:\n  file \(file => directory\)')
718
713
        tree.rename_one('file', 'directory')
719
 
        self.assertStatusContains('renamed:\n  file => directory/\n'
 
714
        self.assertStatusContains('renamed:\n  file/ => directory/\n' \
720
715
                                  'modified:\n  directory/\n')
721
716
        rmdir('directory')
722
717
        self.assertStatusContains('removed:\n  file\n')
729
724
        unlink('file')
730
725
        self.build_tree(['file/'])
731
726
        self.assertStatusContains('K  file => file/',
732
 
                                  short=True)
 
727
                                   short=True)
733
728
        tree.rename_one('file', 'directory')
734
729
        self.assertStatusContains('RK  file => directory/',
735
 
                                  short=True)
 
730
                                   short=True)
736
731
        rmdir('directory')
737
732
        self.assertStatusContains('RD  file => directory',
738
 
                                  short=True)
 
733
                                   short=True)
739
734
 
740
735
    def test_status_illegal_revision_specifiers(self):
741
736
        out, err = self.run_bzr('status -r 1..23..123', retcode=3)
767
762
        tree.merge_from_branch(alt.branch)
768
763
        output = self.make_utf8_encoded_stringio()
769
764
        show_tree_status(tree, to_file=output)
770
 
        self.assertContainsRe(output.getvalue(), b'pending merge')
 
765
        self.assertContainsRe(output.getvalue(), 'pending merge')
771
766
        out, err = self.run_bzr('status tree/a')
772
767
        self.assertNotContainsRe(out, 'pending merge')
773
768
 
782
777
            self.build_tree_contents([(filename, b'contents of hello')])
783
778
        except UnicodeEncodeError:
784
779
            raise TestSkipped("can't build unicode working tree in "
785
 
                              "filesystem encoding %s" % sys.getfilesystemencoding())
 
780
                "filesystem encoding %s" % sys.getfilesystemencoding())
786
781
        working_tree.add(filename)
787
782
        return working_tree
788
783
 
801
796
        working_tree = self.make_uncommitted_tree()
802
797
        stdout, stderr = self.run_bzr('status')
803
798
 
804
 
        expected = u"""\
 
799
        self.assertEqual(stdout, u"""\
805
800
added:
806
801
  hell\u00d8
807
 
"""
808
 
        if not PY3:
809
 
            expected = expected.encode('latin-1')
810
 
        self.assertEqual(stdout, expected)
 
802
""".encode('latin-1'))
 
803