~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

[merge] jam-integration 1527, including branch-formats, help text, misc bug fixes.

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.builtins import merge
30
33
from bzrlib.revisionspec import RevisionSpec
31
 
from bzrlib.builtins import merge
32
34
from bzrlib.status import show_status
33
 
from bzrlib.branch import Branch
 
35
from bzrlib.tests import TestCaseInTempDir
 
36
from bzrlib.workingtree import WorkingTree
 
37
 
34
38
 
35
39
class BranchStatus(TestCaseInTempDir):
36
40
    
37
41
    def test_branch_status(self): 
38
42
        """Test basic branch status"""
39
 
        from bzrlib.status import show_status
40
 
        from bzrlib.branch import Branch
41
 
        
42
 
        b = Branch.initialize(u'.')
 
43
        wt = WorkingTree.create_standalone('.')
 
44
        b = wt.branch
43
45
 
44
46
        # status with nothing
45
47
        tof = StringIO()
48
50
 
49
51
        tof = StringIO()
50
52
        self.build_tree(['hello.c', 'bye.c'])
51
 
        b.working_tree().add_pending_merge('pending@pending-0-0')
 
53
        wt.add_pending_merge('pending@pending-0-0')
52
54
        show_status(b, to_file=tof)
53
55
        tof.seek(0)
54
56
        self.assertEquals(tof.readlines(),
61
63
 
62
64
    def test_branch_status_revisions(self):
63
65
        """Tests branch status with revisions"""
64
 
        
65
 
        b = Branch.initialize(u'.')
 
66
        wt = WorkingTree.create_standalone('.')
 
67
        b = wt.branch
66
68
 
67
69
        tof = StringIO()
68
70
        self.build_tree(['hello.c', 'bye.c'])
69
 
        b.working_tree().add('hello.c')
70
 
        b.working_tree().add('bye.c')
71
 
        b.working_tree().commit('Test message')
 
71
        wt.add('hello.c')
 
72
        wt.add('bye.c')
 
73
        wt.commit('Test message')
72
74
 
73
75
        tof = StringIO()
74
76
        revs =[]
83
85
                           '  hello.c\n'])
84
86
 
85
87
        self.build_tree(['more.c'])
86
 
        b.working_tree().add('more.c')
87
 
        b.working_tree().commit('Another test message')
 
88
        wt.add('more.c')
 
89
        wt.commit('Another test message')
88
90
        
89
91
        tof = StringIO()
90
92
        revs.append(RevisionSpec(1))
108
110
    def test_pending(self):
109
111
        """Pending merges display works, including Unicode"""
110
112
        mkdir("./branch")
111
 
        b = Branch.initialize('./branch')
112
 
        b.working_tree().commit("Empty commit 1")
 
113
        wt = WorkingTree.create_standalone('branch')
 
114
        b = wt.branch
 
115
        wt.commit("Empty commit 1")
113
116
        b_2 = b.clone('./copy')
114
 
        b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
 
117
        wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
115
118
        merge(["./branch", -1], [None, None], this_dir = './copy')
116
119
        message = self.status_string(b_2)
117
120
        self.assert_(message.startswith("pending merges:\n"))
128
131
 
129
132
    def test_branch_status_specific_files(self): 
130
133
        """Tests branch status with given specific files"""
131
 
        from cStringIO import StringIO
132
 
        from bzrlib.status import show_status
133
 
        from bzrlib.branch import Branch
134
 
        
135
 
        b = Branch.initialize(u'.')
 
134
        wt = WorkingTree.create_standalone('.')
 
135
        b = wt.branch
136
136
 
137
137
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
138
 
        b.working_tree().add('directory')
139
 
        b.working_tree().add('test.c')
140
 
        b.working_tree().commit('testing')
 
138
        wt.add('directory')
 
139
        wt.add('test.c')
 
140
        wt.commit('testing')
141
141
        
142
142
        tof = StringIO()
143
143
        show_status(b, to_file=tof)
171
171
                          ['unknown:\n',
172
172
                           '  dir2\n'
173
173
                           ])
 
174
 
 
175
 
 
176
class TestStatus(TestCaseInTempDir):
 
177
 
 
178
    def test_status(self):
 
179
        self.run_bzr("init")
 
180
        self.build_tree(['hello.txt'])
 
181
        result = self.run_bzr("status")[0]
 
182
        self.assert_("unknown:\n  hello.txt\n" in result, result)
 
183
        self.run_bzr("add", "hello.txt")
 
184
        result = self.run_bzr("status")[0]
 
185
        self.assert_("added:\n  hello.txt\n" in result, result)
 
186
        self.run_bzr("commit", "-m", "added")
 
187
        result = self.run_bzr("status", "-r", "0..1")[0]
 
188
        self.assert_("added:\n  hello.txt\n" in result, result)
 
189
        self.build_tree(['world.txt'])
 
190
        result = self.run_bzr("status", "-r", "0")[0]
 
191
        self.assert_("added:\n  hello.txt\n" \
 
192
                     "unknown:\n  world.txt\n" in result, result)
 
193
 
 
194
        result2 = self.run_bzr("status", "-r", "0..")[0]
 
195
        self.assertEquals(result2, result)
 
196
 
 
197