~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_status.py

Merge from integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
"""
22
22
 
23
23
 
 
24
from cStringIO import StringIO
 
25
from os import mkdir
 
26
from tempfile import TemporaryFile
 
27
import codecs
 
28
 
24
29
from bzrlib.tests import TestCaseInTempDir
25
30
from bzrlib.revisionspec import RevisionSpec
26
31
from bzrlib.merge import merge
27
 
from cStringIO import StringIO
28
32
from bzrlib.status import show_status
29
33
from bzrlib.branch import Branch
30
 
from os import mkdir
31
34
 
32
35
class BranchStatus(TestCaseInTempDir):
33
36
    
34
37
    def test_branch_status(self): 
35
38
        """Test basic branch status"""
36
 
        from cStringIO import StringIO
37
39
        from bzrlib.status import show_status
38
40
        from bzrlib.branch import Branch
39
41
        
40
 
        b = Branch.initialize('.')
 
42
        b = Branch.initialize(u'.')
41
43
 
42
44
        # status with nothing
43
45
        tof = StringIO()
60
62
    def test_branch_status_revisions(self):
61
63
        """Tests branch status with revisions"""
62
64
        
63
 
        b = Branch.initialize('.')
 
65
        b = Branch.initialize(u'.')
64
66
 
65
67
        tof = StringIO()
66
68
        self.build_tree(['hello.c', 'bye.c'])
96
98
                           '  hello.c\n'])
97
99
 
98
100
    def status_string(self, branch):
99
 
        tof = StringIO()
 
101
        # use a real file rather than StringIO because it doesn't handle
 
102
        # Unicode very well.
 
103
        tof = codecs.getwriter('utf-8')(TemporaryFile())
100
104
        show_status(branch, to_file=tof)
101
105
        tof.seek(0)
102
 
        return tof.getvalue()
 
106
        return tof.read().decode('utf-8')
103
107
 
104
108
    def test_pending(self):
105
 
        """Pending merges display works"""
 
109
        """Pending merges display works, including Unicode"""
106
110
        mkdir("./branch")
107
111
        b = Branch.initialize('./branch')
108
112
        b.working_tree().commit("Empty commit 1")
109
113
        b_2 = b.clone('./copy')
110
 
        b.working_tree().commit("Empty commit 2")
 
114
        b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
111
115
        merge(["./branch", -1], [None, None], this_dir = './copy')
112
116
        message = self.status_string(b_2)
113
117
        self.assert_(message.startswith("pending merges:\n"))
114
118
        self.assert_(message.endswith("Empty commit 2\n")) 
115
119
        b_2.working_tree().commit("merged")
116
120
        # must be long to make sure we see elipsis at the end
117
 
        b.working_tree().commit("Empty commit 3 blah blah blah blah blah blah blah blah blah"
118
 
                 " blah blah blah blah blah blah bleh")
 
121
        b.working_tree().commit("Empty commit 3 " + 
 
122
                                "blah blah blah blah " * 10)
119
123
        merge(["./branch", -1], [None, None], this_dir = './copy')
120
124
        message = self.status_string(b_2)
121
125
        self.assert_(message.startswith("pending merges:\n"))
128
132
        from bzrlib.status import show_status
129
133
        from bzrlib.branch import Branch
130
134
        
131
 
        b = Branch.initialize('.')
 
135
        b = Branch.initialize(u'.')
132
136
 
133
137
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
134
138
        b.working_tree().add('directory')