~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: 2016-04-03 16:32:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6617.
  • Revision ID: jelmer@jelmer.uk-20160403163231-h72bo0uyek2gikw0
Don't put French text in doc/en/user-reference when LANGUAGE=fr_CH.UTF_8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-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
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
 
187
188
        wt2.merge_from_branch(wt.branch)
188
189
        message = self.status_string(wt2, verbose=True)
189
190
        self.assertStartsWith(message, "pending merges:\n")
190
 
        self.assert_("Empty commit 3" in message)
 
191
        self.assertTrue("Empty commit 3" in message)
191
192
        self.assertEndsWith(message, "...\n")
192
193
 
193
194
    def test_tree_status_ignores(self):
247
248
        tof = StringIO()
248
249
        show_tree_status(wt, specific_files=['directory'], to_file=tof)
249
250
        tof.seek(0)
250
 
        self.assertEquals(tof.readlines(),
 
251
        self.assertEqual(tof.readlines(),
251
252
                          ['unknown:\n',
252
253
                           '  directory/hello.c\n'
253
254
                           ])
255
256
        show_tree_status(wt, specific_files=['directory'], to_file=tof,
256
257
                         short=True)
257
258
        tof.seek(0)
258
 
        self.assertEquals(tof.readlines(), ['?   directory/hello.c\n'])
 
259
        self.assertEqual(tof.readlines(), ['?   directory/hello.c\n'])
259
260
 
260
261
        tof = StringIO()
261
262
        show_tree_status(wt, specific_files=['dir2'], to_file=tof)
262
263
        tof.seek(0)
263
 
        self.assertEquals(tof.readlines(),
 
264
        self.assertEqual(tof.readlines(),
264
265
                          ['unknown:\n',
265
266
                           '  dir2/\n'
266
267
                           ])
267
268
        tof = StringIO()
268
269
        show_tree_status(wt, specific_files=['dir2'], to_file=tof, short=True)
269
270
        tof.seek(0)
270
 
        self.assertEquals(tof.readlines(), ['?   dir2/\n'])
 
271
        self.assertEqual(tof.readlines(), ['?   dir2/\n'])
271
272
 
272
273
        tof = StringIO()
273
274
        revs = [RevisionSpec.from_string('0'), RevisionSpec.from_string('1')]
274
275
        show_tree_status(wt, specific_files=['test.c'], to_file=tof,
275
276
                         short=True, revision=revs)
276
277
        tof.seek(0)
277
 
        self.assertEquals(tof.readlines(), ['+N  test.c\n'])
 
278
        self.assertEqual(tof.readlines(), ['+N  test.c\n'])
278
279
 
279
280
        tof = StringIO()
280
281
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
281
282
        tof.seek(0)
282
 
        self.assertEquals(tof.readlines(),
 
283
        self.assertEqual(tof.readlines(),
283
284
                          ['missing:\n',
284
285
                           '  missing.c\n'])
285
286
 
287
288
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
288
289
                         short=True)
289
290
        tof.seek(0)
290
 
        self.assertEquals(tof.readlines(),
 
291
        self.assertEqual(tof.readlines(),
291
292
                          ['+!  missing.c\n'])
292
293
 
293
294
    def test_specific_files_conflicts(self):
569
570
            ],
570
571
            wt)
571
572
        self.run_bzr(['shelve', '--all', '-m', 'bar'])
572
 
        self.build_tree(['spam.c'])
 
573
        self.build_tree(['eggs.c', 'spam.c'])
 
574
        wt.add('eggs.c')
573
575
        wt.add('spam.c')
574
576
        self.assertStatus([
575
577
                'added:\n',
 
578
                '  eggs.c\n',
576
579
                '  spam.c\n',
577
580
                '2 shelves exist. See "bzr shelve --list" for details.\n',
578
581
            ],
579
582
            wt)
 
583
        self.assertStatus([
 
584
                'added:\n',
 
585
                '  spam.c\n',
 
586
            ],
 
587
            wt,
 
588
            specific_files=['spam.c'])
580
589
 
581
590
 
582
591
class CheckoutStatus(BranchStatus):
589
598
    def make_branch_and_tree(self, relpath):
590
599
        source = self.make_branch(pathjoin('..', relpath))
591
600
        checkout = bzrdir.BzrDirMetaFormat1().initialize(relpath)
592
 
        bzrlib.branch.BranchReferenceFormat().initialize(checkout,
593
 
            target_branch=source)
 
601
        checkout.set_branch_reference(source)
594
602
        return checkout.create_workingtree()
595
603
 
596
604
 
619
627
        self.assertContainsRe(result, "added:\n  hello.txt\n" \
620
628
                                      "unknown:\n  world.txt\n")
621
629
        result2 = self.run_bzr("status -r 0..")[0]
622
 
        self.assertEquals(result2, result)
 
630
        self.assertEqual(result2, result)
623
631
 
624
632
    def test_status_short(self):
625
633
        tree = self.make_branch_and_tree('.')
641
649
        self.assertContainsRe(result, "[+]N  hello.txt\n" \
642
650
                                      "[?]   world.txt\n")
643
651
        result2 = self.run_bzr("status -S -r 0..")[0]
644
 
        self.assertEquals(result2, result)
 
652
        self.assertEqual(result2, result)
645
653
 
646
654
    def test_status_versioned(self):
647
655
        tree = self.make_branch_and_tree('.')
663
671
        self.assertContainsRe(result, "added:\n  hello.txt\n")
664
672
        self.assertNotContainsRe(result, "unknown:\n  world.txt\n")
665
673
        result2 = self.run_bzr("status --versioned -r 0..")[0]
666
 
        self.assertEquals(result2, result)
 
674
        self.assertEqual(result2, result)
667
675
 
668
676
    def test_status_SV(self):
669
677
        tree = self.make_branch_and_tree('.')
685
693
        self.assertContainsRe(result, "[+]N  hello.txt\n")
686
694
 
687
695
        result2 = self.run_bzr("status -SV -r 0..")[0]
688
 
        self.assertEquals(result2, result)
 
696
        self.assertEqual(result2, result)
689
697
 
690
698
    def assertStatusContains(self, pattern, short=False):
691
699
        """Run status, and assert it contains the given pattern"""
741
749
 
742
750
        self.run_bzr('merge ../b', working_dir='a')
743
751
        out, err = self.run_bzr('status --no-pending', working_dir='a')
744
 
        self.assertEquals(out, "added:\n  b\n")
 
752
        self.assertEqual(out, "added:\n  b\n")
745
753
 
746
754
    def test_pending_specific_files(self):
747
755
        """With a specific file list, pending merges are not shown."""
779
787
        working_tree = self.make_uncommitted_tree()
780
788
        stdout, stderr = self.run_bzr("status")
781
789
 
782
 
        self.assertEquals(stdout, """\
 
790
        self.assertEqual(stdout, """\
783
791
added:
784
792
  hell?
785
793
""")
789
797
        working_tree = self.make_uncommitted_tree()
790
798
        stdout, stderr = self.run_bzr('status')
791
799
 
792
 
        self.assertEquals(stdout, u"""\
 
800
        self.assertEqual(stdout, u"""\
793
801
added:
794
802
  hell\u00d8
795
803
""".encode('latin-1'))