~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

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