1
# Copyright (C) 2005-2010 Canonical Ltd
1
# Copyright (C) 2005, 2006 Canonical Ltd
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
473
472
self.assertEqual("working tree is out of date, run 'bzr update'\n",
476
def test_status_on_ignored(self):
477
"""Tests branch status on an unversioned file which is considered ignored.
479
See https://bugs.launchpad.net/bzr/+bug/40103
481
tree = self.make_branch_and_tree('.')
483
self.build_tree(['test1.c', 'test1.c~', 'test2.c~'])
484
result = self.run_bzr('status')[0]
485
self.assertContainsRe(result, "unknown:\n test1.c\n")
486
short_result = self.run_bzr('status --short')[0]
487
self.assertContainsRe(short_result, "\? test1.c\n")
489
result = self.run_bzr('status test1.c')[0]
490
self.assertContainsRe(result, "unknown:\n test1.c\n")
491
short_result = self.run_bzr('status --short test1.c')[0]
492
self.assertContainsRe(short_result, "\? test1.c\n")
494
result = self.run_bzr('status test1.c~')[0]
495
self.assertContainsRe(result, "ignored:\n test1.c~\n")
496
short_result = self.run_bzr('status --short test1.c~')[0]
497
self.assertContainsRe(short_result, "I test1.c~\n")
499
result = self.run_bzr('status test1.c~ test2.c~')[0]
500
self.assertContainsRe(result, "ignored:\n test1.c~\n test2.c~\n")
501
short_result = self.run_bzr('status --short test1.c~ test2.c~')[0]
502
self.assertContainsRe(short_result, "I test1.c~\nI test2.c~\n")
504
result = self.run_bzr('status test1.c test1.c~ test2.c~')[0]
505
self.assertContainsRe(result, "unknown:\n test1.c\nignored:\n test1.c~\n test2.c~\n")
506
short_result = self.run_bzr('status --short test1.c test1.c~ test2.c~')[0]
507
self.assertContainsRe(short_result, "\? test1.c\nI test1.c~\nI test2.c~\n")
509
475
def test_status_write_lock(self):
510
476
"""Test that status works without fetching history and
511
477
having a write lock.
521
487
out, err = self.run_bzr('status branch1 -rbranch:branch2')
522
488
self.assertEqual('', out)
524
def test_status_with_shelves(self):
525
"""Ensure that _show_shelve_summary handler works.
527
wt = self.make_branch_and_tree('.')
528
self.build_tree(['hello.c'])
530
self.run_bzr(['shelve', '--all', '-m', 'foo'])
531
self.build_tree(['bye.c'])
533
# As TestCase.setUp clears all hooks, we install this default
534
# post_status hook handler for the test.
535
status.hooks.install_named_hook('post_status',
536
status._show_shelve_summary,
541
'1 shelves exist. See "bzr shelve --list" for details.\n',
546
491
class CheckoutStatus(BranchStatus):
553
498
def make_branch_and_tree(self, relpath):
554
499
source = self.make_branch(pathjoin('..', relpath))
555
500
checkout = bzrdir.BzrDirMetaFormat1().initialize(relpath)
556
bzrlib.branch.BranchReferenceFormat().initialize(checkout,
557
target_branch=source)
501
bzrlib.branch.BranchReferenceFormat().initialize(checkout, source)
558
502
return checkout.create_workingtree()
651
595
result2 = self.run_bzr("status -SV -r 0..")[0]
652
596
self.assertEquals(result2, result)
654
def assertStatusContains(self, pattern, short=False):
598
def assertStatusContains(self, pattern):
655
599
"""Run status, and assert it contains the given pattern"""
657
result = self.run_bzr("status --short")[0]
659
result = self.run_bzr("status")[0]
600
result = self.run_bzr("status --short")[0]
660
601
self.assertContainsRe(result, pattern)
662
def test_kind_change_plain(self):
663
tree = self.make_branch_and_tree('.')
664
self.build_tree(['file'])
666
tree.commit('added file')
668
self.build_tree(['file/'])
669
self.assertStatusContains('kind changed:\n file \(file => directory\)')
670
tree.rename_one('file', 'directory')
671
self.assertStatusContains('renamed:\n file/ => directory/\n' \
672
'modified:\n directory/\n')
674
self.assertStatusContains('removed:\n file\n')
676
603
def test_kind_change_short(self):
677
604
tree = self.make_branch_and_tree('.')
678
605
self.build_tree(['file'])
680
607
tree.commit('added file')
682
609
self.build_tree(['file/'])
683
self.assertStatusContains('K file => file/',
610
self.assertStatusContains('K file => file/')
685
611
tree.rename_one('file', 'directory')
686
self.assertStatusContains('RK file => directory/',
612
self.assertStatusContains('RK file => directory/')
688
613
rmdir('directory')
689
self.assertStatusContains('RD file => directory',
614
self.assertStatusContains('RD file => directory')
692
616
def test_status_illegal_revision_specifiers(self):
693
617
out, err = self.run_bzr('status -r 1..23..123', retcode=3)
727
651
class TestStatusEncodings(TestCaseWithTransport):
654
TestCaseWithTransport.setUp(self)
655
self.user_encoding = osutils._cached_user_encoding
656
self.stdout = sys.stdout
659
osutils._cached_user_encoding = self.user_encoding
660
sys.stdout = self.stdout
661
TestCaseWithTransport.tearDown(self)
729
663
def make_uncommitted_tree(self):
730
664
"""Build a branch with uncommitted unicode named changes in the cwd."""
731
665
working_tree = self.make_branch_and_tree(u'.')
739
673
return working_tree
741
675
def test_stdout_ascii(self):
742
self.overrideAttr(osutils, '_cached_user_encoding', 'ascii')
676
sys.stdout = StringIO()
677
osutils._cached_user_encoding = 'ascii'
743
678
working_tree = self.make_uncommitted_tree()
744
679
stdout, stderr = self.run_bzr("status")
751
686
def test_stdout_latin1(self):
752
self.overrideAttr(osutils, '_cached_user_encoding', 'latin-1')
687
sys.stdout = StringIO()
688
osutils._cached_user_encoding = 'latin-1'
753
689
working_tree = self.make_uncommitted_tree()
754
690
stdout, stderr = self.run_bzr('status')