~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/teststatus.py

Exclude more files from dumb-rsync upload

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
 
 
29
 
from bzrlib.tests import TestCaseInTempDir
 
24
from bzrlib.selftest import TestCaseInTempDir
30
25
from bzrlib.revisionspec import RevisionSpec
31
26
from bzrlib.merge import merge
 
27
from cStringIO import StringIO
32
28
from bzrlib.status import show_status
33
29
from bzrlib.branch import Branch
 
30
from os import mkdir
34
31
from bzrlib.clone import copy_branch
35
32
 
36
33
class BranchStatus(TestCaseInTempDir):
37
34
    
38
35
    def test_branch_status(self): 
39
36
        """Test basic branch status"""
 
37
        from cStringIO import StringIO
40
38
        from bzrlib.status import show_status
41
39
        from bzrlib.branch import Branch
42
40
        
43
 
        b = Branch.initialize(u'.')
 
41
        b = Branch.initialize('.')
44
42
 
45
43
        # status with nothing
46
44
        tof = StringIO()
63
61
    def test_branch_status_revisions(self):
64
62
        """Tests branch status with revisions"""
65
63
        
66
 
        b = Branch.initialize(u'.')
 
64
        b = Branch.initialize('.')
67
65
 
68
66
        tof = StringIO()
69
67
        self.build_tree(['hello.c', 'bye.c'])
70
 
        b.working_tree().add('hello.c')
71
 
        b.working_tree().add('bye.c')
 
68
        b.add('hello.c')
 
69
        b.add('bye.c')
72
70
        b.working_tree().commit('Test message')
73
71
 
74
72
        tof = StringIO()
84
82
                           '  hello.c\n'])
85
83
 
86
84
        self.build_tree(['more.c'])
87
 
        b.working_tree().add('more.c')
 
85
        b.add('more.c')
88
86
        b.working_tree().commit('Another test message')
89
87
        
90
88
        tof = StringIO()
99
97
                           '  hello.c\n'])
100
98
 
101
99
    def status_string(self, branch):
102
 
        # use a real file rather than StringIO because it doesn't handle
103
 
        # Unicode very well.
104
 
        tof = codecs.getwriter('utf-8')(TemporaryFile())
 
100
        tof = StringIO()
105
101
        show_status(branch, to_file=tof)
106
102
        tof.seek(0)
107
 
        return tof.read().decode('utf-8')
 
103
        return tof.getvalue()
108
104
 
109
105
    def test_pending(self):
110
 
        """Pending merges display works, including Unicode"""
 
106
        """Pending merges display works"""
111
107
        mkdir("./branch")
112
108
        b = Branch.initialize('./branch')
113
109
        b.working_tree().commit("Empty commit 1")
114
110
        b_2 = copy_branch(b, './copy')
115
 
        b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
 
111
        b.working_tree().commit("Empty commit 2")
116
112
        merge(["./branch", -1], [None, None], this_dir = './copy')
117
113
        message = self.status_string(b_2)
118
114
        self.assert_(message.startswith("pending merges:\n"))
119
115
        self.assert_(message.endswith("Empty commit 2\n")) 
120
116
        b_2.working_tree().commit("merged")
121
117
        # 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)
 
118
        b.working_tree().commit("Empty commit 3 blah blah blah blah blah blah blah blah blah"
 
119
                 " blah blah blah blah blah blah bleh")
124
120
        merge(["./branch", -1], [None, None], this_dir = './copy')
125
121
        message = self.status_string(b_2)
126
122
        self.assert_(message.startswith("pending merges:\n"))
133
129
        from bzrlib.status import show_status
134
130
        from bzrlib.branch import Branch
135
131
        
136
 
        b = Branch.initialize(u'.')
 
132
        b = Branch.initialize('.')
137
133
 
138
134
        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')
 
135
        b.add('directory')
 
136
        b.add('test.c')
141
137
        b.working_tree().commit('testing')
142
138
        
143
139
        tof = StringIO()