/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 brzlib/tests/blackbox/test_status.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
interface later, they will be non blackbox tests.
23
23
"""
24
24
 
 
25
from cStringIO import StringIO
25
26
import codecs
26
 
from io import (
27
 
    BytesIO,
28
 
    StringIO,
29
 
    )
30
27
from os import mkdir, chdir, rmdir, unlink
31
28
import sys
 
29
from tempfile import TemporaryFile
32
30
 
33
 
from ... import (
 
31
from brzlib import (
 
32
    bzrdir,
34
33
    conflicts,
35
34
    errors,
36
35
    osutils,
37
36
    status,
38
37
    )
39
 
from breezy.bzr import (
40
 
    bzrdir,
41
 
    )
42
 
import breezy.branch
43
 
from ...osutils import pathjoin
44
 
from ...revisionspec import RevisionSpec
45
 
from ...status import show_tree_status
46
 
from .. import TestCaseWithTransport, TestSkipped
47
 
from ...workingtree import WorkingTree
 
38
import brzlib.branch
 
39
from brzlib.osutils import pathjoin
 
40
from brzlib.revisionspec import RevisionSpec
 
41
from brzlib.status import show_tree_status
 
42
from brzlib.tests import TestCaseWithTransport, TestSkipped
 
43
from brzlib.workingtree import WorkingTree
48
44
 
49
45
 
50
46
class BranchStatus(TestCaseWithTransport):
54
50
        # As TestCase.setUp clears all hooks, we install this default
55
51
        # post_status hook handler for the test.
56
52
        status.hooks.install_named_hook('post_status',
57
 
                                        status._show_shelve_summary,
58
 
                                        'brz status')
 
53
            status._show_shelve_summary,
 
54
            'bzr status')
59
55
 
60
56
    def assertStatus(self, expected_lines, working_tree, specific_files=None,
61
 
                     revision=None, short=False, pending=True, verbose=False):
 
57
        revision=None, short=False, pending=True, verbose=False):
62
58
        """Run status in working_tree and look for output.
63
59
 
64
60
        :param expected_lines: The lines to look for.
65
61
        :param working_tree: The tree to run status in.
66
62
        """
67
63
        output_string = self.status_string(working_tree, specific_files, revision, short,
68
 
                                           pending, verbose)
 
64
                pending, verbose)
69
65
        self.assertEqual(expected_lines, output_string.splitlines(True))
70
66
 
71
67
    def status_string(self, wt, specific_files=None, revision=None,
72
 
                      short=False, pending=True, verbose=False):
73
 
        uio = self.make_utf8_encoded_stringio()
74
 
        show_tree_status(wt, specific_files=specific_files, to_file=uio,
75
 
                         revision=revision, short=short, show_pending=pending,
76
 
                         verbose=verbose)
77
 
        return uio.getvalue().decode('utf-8')
 
68
        short=False, pending=True, verbose=False):
 
69
        # use a real file rather than StringIO because it doesn't handle
 
70
        # Unicode very well.
 
71
        tof = codecs.getwriter('utf-8')(TemporaryFile())
 
72
        show_tree_status(wt, specific_files=specific_files, to_file=tof,
 
73
                revision=revision, short=short, show_pending=pending,
 
74
                verbose=verbose)
 
75
        tof.seek(0)
 
76
        return tof.read().decode('utf-8')
78
77
 
79
78
    def test_branch_status(self):
80
79
        """Test basic branch status"""
88
87
 
89
88
        self.build_tree(['hello.c', 'bye.c'])
90
89
        self.assertStatus([
91
 
            'unknown:\n',
92
 
            '  bye.c\n',
93
 
            '  hello.c\n',
 
90
                'unknown:\n',
 
91
                '  bye.c\n',
 
92
                '  hello.c\n',
94
93
            ],
95
94
            wt)
96
95
        self.assertStatus([
97
 
            '?   bye.c\n',
98
 
            '?   hello.c\n',
 
96
                '?   bye.c\n',
 
97
                '?   hello.c\n',
99
98
            ],
100
99
            wt, short=True)
101
100
 
102
101
        # add a commit to allow showing pending merges.
103
102
        wt.commit('create a parent to allow testing merge output')
104
103
 
105
 
        wt.add_parent_tree_id(b'pending@pending-0-0')
 
104
        wt.add_parent_tree_id('pending@pending-0-0')
106
105
        self.assertStatus([
107
 
            'unknown:\n',
108
 
            '  bye.c\n',
109
 
            '  hello.c\n',
110
 
            'pending merge tips: (use -v to see all merge revisions)\n',
111
 
            '  (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',
112
111
            ],
113
112
            wt)
114
113
        self.assertStatus([
115
 
            'unknown:\n',
116
 
            '  bye.c\n',
117
 
            '  hello.c\n',
118
 
            'pending merges:\n',
119
 
            '  (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',
120
119
            ],
121
120
            wt, verbose=True)
122
121
        self.assertStatus([
123
 
            '?   bye.c\n',
124
 
            '?   hello.c\n',
125
 
            'P   (ghost) pending@pending-0-0\n',
 
122
                '?   bye.c\n',
 
123
                '?   hello.c\n',
 
124
                'P   (ghost) pending@pending-0-0\n',
126
125
            ],
127
126
            wt, short=True)
128
127
        self.assertStatus([
129
 
            'unknown:\n',
130
 
            '  bye.c\n',
131
 
            '  hello.c\n',
 
128
                'unknown:\n',
 
129
                '  bye.c\n',
 
130
                '  hello.c\n',
132
131
            ],
133
132
            wt, pending=False)
134
133
        self.assertStatus([
135
 
            '?   bye.c\n',
136
 
            '?   hello.c\n',
 
134
                '?   bye.c\n',
 
135
                '?   hello.c\n',
137
136
            ],
138
137
            wt, short=True, pending=False)
139
138
 
148
147
 
149
148
        revs = [RevisionSpec.from_string('0')]
150
149
        self.assertStatus([
151
 
            'added:\n',
152
 
            '  bye.c\n',
153
 
            '  hello.c\n'
 
150
                'added:\n',
 
151
                '  bye.c\n',
 
152
                '  hello.c\n'
154
153
            ],
155
154
            wt,
156
155
            revision=revs)
161
160
 
162
161
        revs.append(RevisionSpec.from_string('1'))
163
162
        self.assertStatus([
164
 
            'added:\n',
165
 
            '  bye.c\n',
166
 
            '  hello.c\n',
 
163
                'added:\n',
 
164
                '  bye.c\n',
 
165
                '  hello.c\n',
167
166
            ],
168
167
            wt,
169
168
            revision=revs)
174
173
        wt = self.make_branch_and_tree('branch')
175
174
        b = wt.branch
176
175
        wt.commit("Empty commit 1")
177
 
        b_2_dir = b.controldir.sprout('./copy')
 
176
        b_2_dir = b.bzrdir.sprout('./copy')
178
177
        b_2 = b_2_dir.open_branch()
179
178
        wt2 = b_2_dir.open_workingtree()
180
179
        wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
184
183
        self.assertEndsWith(message, "Empty commit 2\n")
185
184
        wt2.commit("merged")
186
185
        # must be long to make sure we see elipsis at the end
187
 
        wt.commit("Empty commit 3 "
188
 
                  + "blah blah blah blah " * 100)
 
186
        wt.commit("Empty commit 3 " +
 
187
                   "blah blah blah blah " * 100)
189
188
        wt2.merge_from_branch(wt.branch)
190
189
        message = self.status_string(wt2, verbose=True)
191
190
        self.assertStartsWith(message, "pending merges:\n")
199
198
        wt.commit('commit .bzrignore')
200
199
        self.build_tree(['foo.c', 'foo.c~'])
201
200
        self.assertStatus([
202
 
            'unknown:\n',
203
 
            '  foo.c\n',
204
 
            ],
205
 
            wt)
 
201
                'unknown:\n',
 
202
                '  foo.c\n',
 
203
                ],
 
204
                wt)
206
205
        self.assertStatus([
207
 
            '?   foo.c\n',
208
 
            ],
209
 
            wt, short=True)
 
206
                '?   foo.c\n',
 
207
                ],
 
208
                wt, short=True)
210
209
 
211
210
    def test_tree_status_specific_files(self):
212
211
        """Tests branch status with given specific files"""
213
212
        wt = self.make_branch_and_tree('.')
214
213
        b = wt.branch
215
214
 
216
 
        self.build_tree(['directory/', 'directory/hello.c',
217
 
                         'bye.c', 'test.c', 'dir2/',
 
215
        self.build_tree(['directory/','directory/hello.c',
 
216
                         'bye.c','test.c','dir2/',
218
217
                         'missing.c'])
219
218
        wt.add('directory')
220
219
        wt.add('test.c')
223
222
        unlink('missing.c')
224
223
 
225
224
        self.assertStatus([
226
 
            'missing:\n',
227
 
            '  missing.c\n',
228
 
            'unknown:\n',
229
 
            '  bye.c\n',
230
 
            '  dir2/\n',
231
 
            '  directory/hello.c\n'
232
 
            ],
233
 
            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)
234
233
 
235
234
        self.assertStatus([
236
 
            '?   bye.c\n',
237
 
            '?   dir2/\n',
238
 
            '?   directory/hello.c\n',
239
 
            '+!  missing.c\n',
240
 
            ],
241
 
            wt, short=True)
 
235
                '?   bye.c\n',
 
236
                '?   dir2/\n',
 
237
                '+!  missing.c\n',
 
238
                '?   directory/hello.c\n'
 
239
                ],
 
240
                wt, short=True)
242
241
 
243
242
        tof = StringIO()
244
243
        self.assertRaises(errors.PathsDoNotExist,
245
244
                          show_tree_status,
246
 
                          wt, specific_files=['bye.c', 'test.c', 'absent.c'],
 
245
                          wt, specific_files=['bye.c','test.c','absent.c'],
247
246
                          to_file=tof)
248
247
 
249
248
        tof = StringIO()
250
249
        show_tree_status(wt, specific_files=['directory'], to_file=tof)
251
250
        tof.seek(0)
252
251
        self.assertEqual(tof.readlines(),
253
 
                         ['unknown:\n',
254
 
                          '  directory/hello.c\n'
255
 
                          ])
 
252
                          ['unknown:\n',
 
253
                           '  directory/hello.c\n'
 
254
                           ])
256
255
        tof = StringIO()
257
256
        show_tree_status(wt, specific_files=['directory'], to_file=tof,
258
257
                         short=True)
263
262
        show_tree_status(wt, specific_files=['dir2'], to_file=tof)
264
263
        tof.seek(0)
265
264
        self.assertEqual(tof.readlines(),
266
 
                         ['unknown:\n',
267
 
                          '  dir2/\n'
268
 
                          ])
 
265
                          ['unknown:\n',
 
266
                           '  dir2/\n'
 
267
                           ])
269
268
        tof = StringIO()
270
269
        show_tree_status(wt, specific_files=['dir2'], to_file=tof, short=True)
271
270
        tof.seek(0)
282
281
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
283
282
        tof.seek(0)
284
283
        self.assertEqual(tof.readlines(),
285
 
                         ['missing:\n',
286
 
                          '  missing.c\n'])
 
284
                          ['missing:\n',
 
285
                           '  missing.c\n'])
287
286
 
288
287
        tof = StringIO()
289
288
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
290
289
                         short=True)
291
290
        tof.seek(0)
292
291
        self.assertEqual(tof.readlines(),
293
 
                         ['+!  missing.c\n'])
 
292
                          ['+!  missing.c\n'])
294
293
 
295
294
    def test_specific_files_conflicts(self):
296
295
        tree = self.make_branch_and_tree('.')
299
298
        tree.commit('added dir2')
300
299
        tree.set_conflicts(conflicts.ConflictList(
301
300
            [conflicts.ContentsConflict('foo')]))
302
 
        tof = BytesIO()
 
301
        tof = StringIO()
303
302
        show_tree_status(tree, specific_files=['dir2'], to_file=tof)
304
 
        self.assertEqualDiff(b'', tof.getvalue())
 
303
        self.assertEqualDiff('', tof.getvalue())
305
304
        tree.set_conflicts(conflicts.ConflictList(
306
305
            [conflicts.ContentsConflict('dir2')]))
307
306
        tof = StringIO()
326
325
        wt.add('FILE_D')
327
326
        wt.add('FILE_E')
328
327
        wt.commit('Create five empty files.')
329
 
        with open('FILE_B', 'w') as f:
330
 
            f.write('Modification to file FILE_B.')
331
 
        with open('FILE_C', 'w') as f:
332
 
            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.')
333
330
        unlink('FILE_E')  # FILE_E will be versioned but missing
334
 
        with open('FILE_Q', 'w') as f:
335
 
            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.')
336
332
        wt.add('FILE_Q')  # FILE_Q will be added but not committed
337
333
        open('UNVERSIONED_BUT_EXISTING', 'w')
338
334
        return wt
365
361
        # Okay, everything's looking good with the existent files.
366
362
        # Let's see what happens when we throw in non-existent files.
367
363
 
368
 
        # brz st [--short] NONEXISTENT '
 
364
        # bzr st [--short] NONEXISTENT '
369
365
        expected = [
370
 
            'nonexistent:\n',
371
 
            '  NONEXISTENT\n',
372
 
            ]
 
366
          'nonexistent:\n',
 
367
          '  NONEXISTENT\n',
 
368
          ]
373
369
        out, err = self.run_bzr('status NONEXISTENT', retcode=3)
374
370
        self.assertEqual(expected, out.splitlines(True))
375
371
        self.assertContainsRe(err,
376
372
                              r'.*ERROR: Path\(s\) do not exist: '
377
373
                              'NONEXISTENT.*')
378
374
        expected = [
379
 
            'X:   NONEXISTENT\n',
380
 
            ]
 
375
          'X:   NONEXISTENT\n',
 
376
          ]
381
377
        out, err = self.run_bzr('status --short NONEXISTENT', retcode=3)
382
378
        self.assertContainsRe(err,
383
379
                              r'.*ERROR: Path\(s\) do not exist: '
384
380
                              'NONEXISTENT.*')
385
381
 
386
382
    def test_status_nonexistent_file_with_others(self):
387
 
        # brz st [--short] NONEXISTENT ...others..
 
383
        # bzr st [--short] NONEXISTENT ...others..
388
384
        wt = self._prepare_nonexistent()
389
385
        expected = [
390
 
            'removed:\n',
391
 
            '  FILE_E\n',
392
 
            'modified:\n',
393
 
            '  FILE_B\n',
394
 
            '  FILE_C\n',
395
 
            'nonexistent:\n',
396
 
            '  NONEXISTENT\n',
397
 
            ]
 
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
          ]
398
394
        out, err = self.run_bzr('status NONEXISTENT '
399
395
                                'FILE_A FILE_B FILE_C FILE_D FILE_E',
400
396
                                retcode=3)
403
399
                              r'.*ERROR: Path\(s\) do not exist: '
404
400
                              'NONEXISTENT.*')
405
401
        expected = [
406
 
            ' M  FILE_B\n',
407
 
            ' M  FILE_C\n',
408
 
            ' D  FILE_E\n',
409
 
            'X   NONEXISTENT\n',
410
 
            ]
 
402
          ' D  FILE_E\n',
 
403
          ' M  FILE_C\n',
 
404
          ' M  FILE_B\n',
 
405
          'X   NONEXISTENT\n',
 
406
          ]
411
407
        out, err = self.run_bzr('status --short NONEXISTENT '
412
408
                                'FILE_A FILE_B FILE_C FILE_D FILE_E',
413
409
                                retcode=3)
417
413
                              'NONEXISTENT.*')
418
414
 
419
415
    def test_status_multiple_nonexistent_files(self):
420
 
        # brz st [--short] NONEXISTENT ... ANOTHER_NONEXISTENT ...
 
416
        # bzr st [--short] NONEXISTENT ... ANOTHER_NONEXISTENT ...
421
417
        wt = self._prepare_nonexistent()
422
418
        expected = [
423
 
            'removed:\n',
424
 
            '  FILE_E\n',
425
 
            'modified:\n',
426
 
            '  FILE_B\n',
427
 
            '  FILE_C\n',
428
 
            'nonexistent:\n',
429
 
            '  ANOTHER_NONEXISTENT\n',
430
 
            '  NONEXISTENT\n',
431
 
            ]
 
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
          ]
432
428
        out, err = self.run_bzr('status NONEXISTENT '
433
429
                                'FILE_A FILE_B ANOTHER_NONEXISTENT '
434
430
                                'FILE_C FILE_D FILE_E', retcode=3)
437
433
                              r'.*ERROR: Path\(s\) do not exist: '
438
434
                              'ANOTHER_NONEXISTENT NONEXISTENT.*')
439
435
        expected = [
440
 
            ' M  FILE_B\n',
441
 
            ' M  FILE_C\n',
442
 
            ' D  FILE_E\n',
443
 
            'X   ANOTHER_NONEXISTENT\n',
444
 
            'X   NONEXISTENT\n',
445
 
            ]
 
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
          ]
446
442
        out, err = self.run_bzr('status --short NONEXISTENT '
447
443
                                'FILE_A FILE_B ANOTHER_NONEXISTENT '
448
444
                                'FILE_C FILE_D FILE_E', retcode=3)
452
448
                              'ANOTHER_NONEXISTENT NONEXISTENT.*')
453
449
 
454
450
    def test_status_nonexistent_file_with_unversioned(self):
455
 
        # brz st [--short] NONEXISTENT A B UNVERSIONED_BUT_EXISTING C D E Q
 
451
        # bzr st [--short] NONEXISTENT A B UNVERSIONED_BUT_EXISTING C D E Q
456
452
        wt = self._prepare_nonexistent()
457
453
        expected = [
458
 
            'removed:\n',
459
 
            '  FILE_E\n',
460
 
            'added:\n',
461
 
            '  FILE_Q\n',
462
 
            'modified:\n',
463
 
            '  FILE_B\n',
464
 
            '  FILE_C\n',
465
 
            'unknown:\n',
466
 
            '  UNVERSIONED_BUT_EXISTING\n',
467
 
            'nonexistent:\n',
468
 
            '  NONEXISTENT\n',
469
 
            ]
 
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
          ]
470
466
        out, err = self.run_bzr('status NONEXISTENT '
471
467
                                'FILE_A FILE_B UNVERSIONED_BUT_EXISTING '
472
468
                                'FILE_C FILE_D FILE_E FILE_Q', retcode=3)
474
470
        self.assertContainsRe(err,
475
471
                              r'.*ERROR: Path\(s\) do not exist: '
476
472
                              'NONEXISTENT.*')
477
 
        expected = sorted([
478
 
            '+N  FILE_Q\n',
479
 
            '?   UNVERSIONED_BUT_EXISTING\n',
480
 
            ' D  FILE_E\n',
481
 
            ' M  FILE_C\n',
482
 
            ' M  FILE_B\n',
483
 
            'X   NONEXISTENT\n',
484
 
            ])
 
473
        expected = [
 
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
          ]
 
481
        expected.sort()
485
482
        out, err = self.run_bzr('status --short NONEXISTENT '
486
483
                                'FILE_A FILE_B UNVERSIONED_BUT_EXISTING '
487
484
                                'FILE_C FILE_D FILE_E FILE_Q', retcode=3)
495
492
    def test_status_out_of_date(self):
496
493
        """Simulate status of out-of-date tree after remote push"""
497
494
        tree = self.make_branch_and_tree('.')
498
 
        self.build_tree_contents([('a', b'foo\n')])
499
 
        with tree.lock_write():
 
495
        self.build_tree_contents([('a', 'foo\n')])
 
496
        tree.lock_write()
 
497
        try:
500
498
            tree.add(['a'])
501
499
            tree.commit('add test file')
502
500
            # simulate what happens after a remote push
503
 
            tree.set_last_revision(b"0")
 
501
            tree.set_last_revision("0")
 
502
        finally:
 
503
            # before run another commands we should unlock tree
 
504
            tree.unlock()
504
505
        out, err = self.run_bzr('status')
505
 
        self.assertEqual("working tree is out of date, run 'brz update'\n",
 
506
        self.assertEqual("working tree is out of date, run 'bzr update'\n",
506
507
                         err)
507
508
 
508
509
    def test_status_on_ignored(self):
516
517
        result = self.run_bzr('status')[0]
517
518
        self.assertContainsRe(result, "unknown:\n  test1.c\n")
518
519
        short_result = self.run_bzr('status --short')[0]
519
 
        self.assertContainsRe(short_result, "\\?   test1.c\n")
 
520
        self.assertContainsRe(short_result, "\?   test1.c\n")
520
521
 
521
522
        result = self.run_bzr('status test1.c')[0]
522
523
        self.assertContainsRe(result, "unknown:\n  test1.c\n")
523
524
        short_result = self.run_bzr('status --short test1.c')[0]
524
 
        self.assertContainsRe(short_result, "\\?   test1.c\n")
 
525
        self.assertContainsRe(short_result, "\?   test1.c\n")
525
526
 
526
527
        result = self.run_bzr('status test1.c~')[0]
527
528
        self.assertContainsRe(result, "ignored:\n  test1.c~\n")
534
535
        self.assertContainsRe(short_result, "I   test1.c~\nI   test2.c~\n")
535
536
 
536
537
        result = self.run_bzr('status test1.c test1.c~ test2.c~')[0]
537
 
        self.assertContainsRe(
538
 
            result, "unknown:\n  test1.c\nignored:\n  test1.c~\n  test2.c~\n")
539
 
        short_result = self.run_bzr(
540
 
            'status --short test1.c test1.c~ test2.c~')[0]
541
 
        self.assertContainsRe(
542
 
            short_result, "\\?   test1.c\nI   test1.c~\nI   test2.c~\n")
 
538
        self.assertContainsRe(result, "unknown:\n  test1.c\nignored:\n  test1.c~\n  test2.c~\n")
 
539
        short_result = self.run_bzr('status --short test1.c test1.c~ test2.c~')[0]
 
540
        self.assertContainsRe(short_result, "\?   test1.c\nI   test1.c~\nI   test2.c~\n")
543
541
 
544
542
    def test_status_write_lock(self):
545
543
        """Test that status works without fetching history and
551
549
        wt = self.make_branch_and_tree('branch1')
552
550
        b = wt.branch
553
551
        wt.commit('Empty commit 1')
554
 
        wt2 = b.controldir.sprout('branch2').open_workingtree()
 
552
        wt2 = b.bzrdir.sprout('branch2').open_workingtree()
555
553
        wt2.commit('Empty commit 2')
556
554
        out, err = self.run_bzr('status branch1 -rbranch:branch2')
557
555
        self.assertEqual('', out)
566
564
        self.build_tree(['bye.c'])
567
565
        wt.add('bye.c')
568
566
        self.assertStatus([
569
 
            'added:\n',
570
 
            '  bye.c\n',
571
 
            '1 shelf exists. See "brz shelve --list" for details.\n',
 
567
                'added:\n',
 
568
                '  bye.c\n',
 
569
                '1 shelf exists. See "bzr shelve --list" for details.\n',
572
570
            ],
573
571
            wt)
574
572
        self.run_bzr(['shelve', '--all', '-m', 'bar'])
576
574
        wt.add('eggs.c')
577
575
        wt.add('spam.c')
578
576
        self.assertStatus([
579
 
            'added:\n',
580
 
            '  eggs.c\n',
581
 
            '  spam.c\n',
582
 
            '2 shelves exist. See "brz shelve --list" for details.\n',
 
577
                'added:\n',
 
578
                '  eggs.c\n',
 
579
                '  spam.c\n',
 
580
                '2 shelves exist. See "bzr shelve --list" for details.\n',
583
581
            ],
584
582
            wt)
585
583
        self.assertStatus([
586
 
            'added:\n',
587
 
            '  spam.c\n',
 
584
                'added:\n',
 
585
                '  spam.c\n',
588
586
            ],
589
587
            wt,
590
588
            specific_files=['spam.c'])
626
624
 
627
625
        self.build_tree(['world.txt'])
628
626
        result = self.run_bzr("status -r 0")[0]
629
 
        self.assertContainsRe(result, "added:\n  hello.txt\n"
 
627
        self.assertContainsRe(result, "added:\n  hello.txt\n" \
630
628
                                      "unknown:\n  world.txt\n")
631
629
        result2 = self.run_bzr("status -r 0..")[0]
632
630
        self.assertEqual(result2, result)
648
646
 
649
647
        self.build_tree(['world.txt'])
650
648
        result = self.run_bzr("status -S -r 0")[0]
651
 
        self.assertContainsRe(result, "[+]N  hello.txt\n"
 
649
        self.assertContainsRe(result, "[+]N  hello.txt\n" \
652
650
                                      "[?]   world.txt\n")
653
651
        result2 = self.run_bzr("status -S -r 0..")[0]
654
652
        self.assertEqual(result2, result)
712
710
        tree.commit('added file')
713
711
        unlink('file')
714
712
        self.build_tree(['file/'])
715
 
        self.assertStatusContains(
716
 
            'kind changed:\n  file \\(file => directory\\)')
 
713
        self.assertStatusContains('kind changed:\n  file \(file => directory\)')
717
714
        tree.rename_one('file', 'directory')
718
 
        self.assertStatusContains('renamed:\n  file => directory/\n'
 
715
        self.assertStatusContains('renamed:\n  file/ => directory/\n' \
719
716
                                  'modified:\n  directory/\n')
720
717
        rmdir('directory')
721
718
        self.assertStatusContains('removed:\n  file\n')
728
725
        unlink('file')
729
726
        self.build_tree(['file/'])
730
727
        self.assertStatusContains('K  file => file/',
731
 
                                  short=True)
 
728
                                   short=True)
732
729
        tree.rename_one('file', 'directory')
733
730
        self.assertStatusContains('RK  file => directory/',
734
 
                                  short=True)
 
731
                                   short=True)
735
732
        rmdir('directory')
736
733
        self.assertStatusContains('RD  file => directory',
737
 
                                  short=True)
 
734
                                   short=True)
738
735
 
739
736
    def test_status_illegal_revision_specifiers(self):
740
737
        out, err = self.run_bzr('status -r 1..23..123', retcode=3)
745
742
        self.build_tree(['a/a'])
746
743
        a_tree.add('a')
747
744
        a_tree.commit('a')
748
 
        b_tree = a_tree.controldir.sprout('b').open_workingtree()
 
745
        b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
749
746
        self.build_tree(['b/b'])
750
747
        b_tree.add('b')
751
748
        b_tree.commit('b')
757
754
    def test_pending_specific_files(self):
758
755
        """With a specific file list, pending merges are not shown."""
759
756
        tree = self.make_branch_and_tree('tree')
760
 
        self.build_tree_contents([('tree/a', b'content of a\n')])
 
757
        self.build_tree_contents([('tree/a', 'content of a\n')])
761
758
        tree.add('a')
762
759
        r1_id = tree.commit('one')
763
 
        alt = tree.controldir.sprout('alt').open_workingtree()
764
 
        self.build_tree_contents([('alt/a', b'content of a\nfrom alt\n')])
 
760
        alt = tree.bzrdir.sprout('alt').open_workingtree()
 
761
        self.build_tree_contents([('alt/a', 'content of a\nfrom alt\n')])
765
762
        alt_id = alt.commit('alt')
766
763
        tree.merge_from_branch(alt.branch)
767
764
        output = self.make_utf8_encoded_stringio()
768
765
        show_tree_status(tree, to_file=output)
769
 
        self.assertContainsRe(output.getvalue(), b'pending merge')
 
766
        self.assertContainsRe(output.getvalue(), 'pending merge')
770
767
        out, err = self.run_bzr('status tree/a')
771
768
        self.assertNotContainsRe(out, 'pending merge')
772
769
 
778
775
        working_tree = self.make_branch_and_tree(u'.')
779
776
        filename = u'hell\u00d8'
780
777
        try:
781
 
            self.build_tree_contents([(filename, b'contents of hello')])
 
778
            self.build_tree_contents([(filename, 'contents of hello')])
782
779
        except UnicodeEncodeError:
783
780
            raise TestSkipped("can't build unicode working tree in "
784
 
                              "filesystem encoding %s" % sys.getfilesystemencoding())
 
781
                "filesystem encoding %s" % sys.getfilesystemencoding())
785
782
        working_tree.add(filename)
786
783
        return working_tree
787
784
 
800
797
        working_tree = self.make_uncommitted_tree()
801
798
        stdout, stderr = self.run_bzr('status')
802
799
 
803
 
        expected = u"""\
 
800
        self.assertEqual(stdout, u"""\
804
801
added:
805
802
  hell\u00d8
806
 
"""
807
 
        self.assertEqual(stdout, expected)
 
803
""".encode('latin-1'))
 
804