~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2011-12-16 19:18:39 UTC
  • mto: This revision was merged to the branch mainline in revision 6391.
  • Revision ID: jelmer@samba.org-20111216191839-eg681lxqibi1qxu1
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
            status._show_shelve_summary,
54
54
            'bzr status')
55
55
 
56
 
    def assertStatus(self, expected_lines, working_tree,
 
56
    def assertStatus(self, expected_lines, working_tree, specific_files=None,
57
57
        revision=None, short=False, pending=True, verbose=False):
58
58
        """Run status in working_tree and look for output.
59
59
 
60
60
        :param expected_lines: The lines to look for.
61
61
        :param working_tree: The tree to run status in.
62
62
        """
63
 
        output_string = self.status_string(working_tree, revision, short,
 
63
        output_string = self.status_string(working_tree, specific_files, revision, short,
64
64
                pending, verbose)
65
65
        self.assertEqual(expected_lines, output_string.splitlines(True))
66
66
 
67
 
    def status_string(self, wt, revision=None, short=False, pending=True,
68
 
        verbose=False):
 
67
    def status_string(self, wt, specific_files=None, revision=None,
 
68
        short=False, pending=True, verbose=False):
69
69
        # use a real file rather than StringIO because it doesn't handle
70
70
        # Unicode very well.
71
71
        tof = codecs.getwriter('utf-8')(TemporaryFile())
72
 
        show_tree_status(wt, to_file=tof, revision=revision, short=short,
73
 
                show_pending=pending, verbose=verbose)
 
72
        show_tree_status(wt, specific_files=specific_files, to_file=tof,
 
73
                revision=revision, short=short, show_pending=pending,
 
74
                verbose=verbose)
74
75
        tof.seek(0)
75
76
        return tof.read().decode('utf-8')
76
77
 
211
212
        wt = self.make_branch_and_tree('.')
212
213
        b = wt.branch
213
214
 
214
 
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
 
215
        self.build_tree(['directory/','directory/hello.c',
 
216
                         'bye.c','test.c','dir2/',
 
217
                         'missing.c'])
215
218
        wt.add('directory')
216
219
        wt.add('test.c')
217
220
        wt.commit('testing')
 
221
        wt.add('missing.c')
 
222
        unlink('missing.c')
218
223
 
219
224
        self.assertStatus([
 
225
                'missing:\n',
 
226
                '  missing.c\n',
220
227
                'unknown:\n',
221
228
                '  bye.c\n',
222
229
                '  dir2/\n',
227
234
        self.assertStatus([
228
235
                '?   bye.c\n',
229
236
                '?   dir2/\n',
 
237
                '+!  missing.c\n',
230
238
                '?   directory/hello.c\n'
231
239
                ],
232
240
                wt, short=True)
269
277
        tof.seek(0)
270
278
        self.assertEquals(tof.readlines(), ['+N  test.c\n'])
271
279
 
 
280
        tof = StringIO()
 
281
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
 
282
        tof.seek(0)
 
283
        self.assertEquals(tof.readlines(),
 
284
                          ['missing:\n',
 
285
                           '  missing.c\n'])
 
286
 
 
287
        tof = StringIO()
 
288
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
 
289
                         short=True)
 
290
        tof.seek(0)
 
291
        self.assertEquals(tof.readlines(),
 
292
                          ['+!  missing.c\n'])
 
293
 
272
294
    def test_specific_files_conflicts(self):
273
295
        tree = self.make_branch_and_tree('.')
274
296
        self.build_tree(['dir2/'])
303
325
        wt.add('FILE_D')
304
326
        wt.add('FILE_E')
305
327
        wt.commit('Create five empty files.')
306
 
        open('FILE_B', 'w').write('Modification to file FILE_B.')
307
 
        open('FILE_C', 'w').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.')
308
330
        unlink('FILE_E')  # FILE_E will be versioned but missing
309
 
        open('FILE_Q', 'w').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.')
310
332
        wt.add('FILE_Q')  # FILE_Q will be added but not committed
311
333
        open('UNVERSIONED_BUT_EXISTING', 'w')
312
334
        return wt
456
478
          ' M  FILE_B\n',
457
479
          'X   NONEXISTENT\n',
458
480
          ]
 
481
        expected.sort()
459
482
        out, err = self.run_bzr('status --short NONEXISTENT '
460
483
                                'FILE_A FILE_B UNVERSIONED_BUT_EXISTING '
461
484
                                'FILE_C FILE_D FILE_E FILE_Q', retcode=3)
462
 
        self.assertEqual(expected, out.splitlines(True))
 
485
        actual = out.splitlines(True)
 
486
        actual.sort()
 
487
        self.assertEqual(expected, actual)
463
488
        self.assertContainsRe(err,
464
489
                              r'.*ERROR: Path\(s\) do not exist: '
465
490
                              'NONEXISTENT.*')
541
566
        self.assertStatus([
542
567
                'added:\n',
543
568
                '  bye.c\n',
544
 
                '1 shelves exist. See "bzr shelve --list" for details.\n',
545
 
            ],
546
 
            wt)
 
569
                '1 shelf exists. See "bzr shelve --list" for details.\n',
 
570
            ],
 
571
            wt)
 
572
        self.run_bzr(['shelve', '--all', '-m', 'bar'])
 
573
        self.build_tree(['eggs.c', 'spam.c'])
 
574
        wt.add('eggs.c')
 
575
        wt.add('spam.c')
 
576
        self.assertStatus([
 
577
                'added:\n',
 
578
                '  eggs.c\n',
 
579
                '  spam.c\n',
 
580
                '2 shelves exist. See "bzr shelve --list" for details.\n',
 
581
            ],
 
582
            wt)
 
583
        self.assertStatus([
 
584
                'added:\n',
 
585
                '  spam.c\n',
 
586
            ],
 
587
            wt,
 
588
            specific_files=['spam.c'])
547
589
 
548
590
 
549
591
class CheckoutStatus(BranchStatus):
604
646
        self.assertContainsRe(result, "[+]N  hello.txt\n")
605
647
 
606
648
        self.build_tree(['world.txt'])
607
 
        result = self.run_bzr("status --short -r 0")[0]
 
649
        result = self.run_bzr("status -S -r 0")[0]
608
650
        self.assertContainsRe(result, "[+]N  hello.txt\n" \
609
651
                                      "[?]   world.txt\n")
610
 
        result2 = self.run_bzr("status --short -r 0..")[0]
 
652
        result2 = self.run_bzr("status -S -r 0..")[0]
611
653
        self.assertEquals(result2, result)
612
654
 
613
655
    def test_status_versioned(self):