~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge in bzrdir work to enable checkout improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""Tests of status command.
19
19
 
20
20
Most of these depend on the particular formatting used.
 
21
As such they really are blackbox tests even though some of the 
 
22
tests are not using self.capture. If we add tests for the programmatic
 
23
interface later, they will be non blackbox tests.
21
24
"""
22
25
 
23
26
 
26
29
from tempfile import TemporaryFile
27
30
import codecs
28
31
 
29
 
from bzrlib.tests import TestCaseInTempDir
 
32
from bzrlib.branch import Branch
 
33
from bzrlib.builtins import merge
30
34
from bzrlib.revisionspec import RevisionSpec
31
 
from bzrlib.merge import merge
32
35
from bzrlib.status import show_status
33
 
from bzrlib.branch import Branch
34
 
from bzrlib.clone import copy_branch
35
 
 
36
 
class BranchStatus(TestCaseInTempDir):
 
36
from bzrlib.tests import TestCaseWithTransport
 
37
from bzrlib.workingtree import WorkingTree
 
38
 
 
39
 
 
40
class BranchStatus(TestCaseWithTransport):
37
41
    
38
42
    def test_branch_status(self): 
39
43
        """Test basic branch status"""
40
 
        from bzrlib.status import show_status
41
 
        from bzrlib.branch import Branch
42
 
        
43
 
        b = Branch.initialize(u'.')
 
44
        wt = self.make_branch_and_tree('.')
 
45
        b = wt.branch
44
46
 
45
47
        # status with nothing
46
48
        tof = StringIO()
49
51
 
50
52
        tof = StringIO()
51
53
        self.build_tree(['hello.c', 'bye.c'])
52
 
        b.working_tree().add_pending_merge('pending@pending-0-0')
 
54
        wt.add_pending_merge('pending@pending-0-0')
53
55
        show_status(b, to_file=tof)
54
56
        tof.seek(0)
55
57
        self.assertEquals(tof.readlines(),
62
64
 
63
65
    def test_branch_status_revisions(self):
64
66
        """Tests branch status with revisions"""
65
 
        
66
 
        b = Branch.initialize(u'.')
 
67
        wt = self.make_branch_and_tree('.')
 
68
        b = wt.branch
67
69
 
68
70
        tof = StringIO()
69
71
        self.build_tree(['hello.c', 'bye.c'])
70
 
        b.working_tree().add('hello.c')
71
 
        b.working_tree().add('bye.c')
72
 
        b.working_tree().commit('Test message')
 
72
        wt.add('hello.c')
 
73
        wt.add('bye.c')
 
74
        wt.commit('Test message')
73
75
 
74
76
        tof = StringIO()
75
77
        revs =[]
84
86
                           '  hello.c\n'])
85
87
 
86
88
        self.build_tree(['more.c'])
87
 
        b.working_tree().add('more.c')
88
 
        b.working_tree().commit('Another test message')
 
89
        wt.add('more.c')
 
90
        wt.commit('Another test message')
89
91
        
90
92
        tof = StringIO()
91
93
        revs.append(RevisionSpec(1))
109
111
    def test_pending(self):
110
112
        """Pending merges display works, including Unicode"""
111
113
        mkdir("./branch")
112
 
        b = Branch.initialize('./branch')
113
 
        b.working_tree().commit("Empty commit 1")
114
 
        b_2 = copy_branch(b, './copy')
115
 
        b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
 
114
        wt = self.make_branch_and_tree('branch')
 
115
        b = wt.branch
 
116
        wt.commit("Empty commit 1")
 
117
        b_2_dir = b.bzrdir.sprout('./copy')
 
118
        b_2 = b_2_dir.open_branch()
 
119
        wt2 = b_2_dir.open_workingtree()
 
120
        wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
116
121
        merge(["./branch", -1], [None, None], this_dir = './copy')
117
122
        message = self.status_string(b_2)
118
123
        self.assert_(message.startswith("pending merges:\n"))
119
124
        self.assert_(message.endswith("Empty commit 2\n")) 
120
 
        b_2.working_tree().commit("merged")
 
125
        wt2.commit("merged")
121
126
        # must be long to make sure we see elipsis at the end
122
 
        b.working_tree().commit("Empty commit 3 " + 
123
 
                                "blah blah blah blah " * 10)
 
127
        wt.commit("Empty commit 3 " + 
 
128
                   "blah blah blah blah " * 10)
124
129
        merge(["./branch", -1], [None, None], this_dir = './copy')
125
130
        message = self.status_string(b_2)
126
131
        self.assert_(message.startswith("pending merges:\n"))
129
134
 
130
135
    def test_branch_status_specific_files(self): 
131
136
        """Tests branch status with given specific files"""
132
 
        from cStringIO import StringIO
133
 
        from bzrlib.status import show_status
134
 
        from bzrlib.branch import Branch
135
 
        
136
 
        b = Branch.initialize(u'.')
 
137
        wt = self.make_branch_and_tree('.')
 
138
        b = wt.branch
137
139
 
138
140
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
139
 
        b.working_tree().add('directory')
140
 
        b.working_tree().add('test.c')
141
 
        b.working_tree().commit('testing')
 
141
        wt.add('directory')
 
142
        wt.add('test.c')
 
143
        wt.commit('testing')
142
144
        
143
145
        tof = StringIO()
144
146
        show_status(b, to_file=tof)