~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge bzr.dev

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.clone import copy_branch
 
33
from bzrlib.branch import Branch
 
34
from bzrlib.builtins import merge
30
35
from bzrlib.revisionspec import RevisionSpec
31
 
from bzrlib.builtins import merge
32
36
from bzrlib.status import show_status
33
 
from bzrlib.branch import Branch
 
37
from bzrlib.tests import TestCaseInTempDir
 
38
from bzrlib.workingtree import WorkingTree
 
39
 
34
40
 
35
41
class BranchStatus(TestCaseInTempDir):
36
42
    
37
43
    def test_branch_status(self): 
38
44
        """Test basic branch status"""
39
 
        from bzrlib.status import show_status
40
 
        from bzrlib.branch import Branch
41
 
        
42
 
        b = Branch.initialize(u'.')
 
45
        wt = WorkingTree.create_standalone('.')
 
46
        b = wt.branch
43
47
 
44
48
        # status with nothing
45
49
        tof = StringIO()
48
52
 
49
53
        tof = StringIO()
50
54
        self.build_tree(['hello.c', 'bye.c'])
51
 
        b.working_tree().add_pending_merge('pending@pending-0-0')
 
55
        wt.add_pending_merge('pending@pending-0-0')
52
56
        show_status(b, to_file=tof)
53
57
        tof.seek(0)
54
58
        self.assertEquals(tof.readlines(),
61
65
 
62
66
    def test_branch_status_revisions(self):
63
67
        """Tests branch status with revisions"""
64
 
        
65
 
        b = Branch.initialize(u'.')
 
68
        wt = WorkingTree.create_standalone('.')
 
69
        b = wt.branch
66
70
 
67
71
        tof = StringIO()
68
72
        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')
 
73
        wt.add('hello.c')
 
74
        wt.add('bye.c')
 
75
        wt.commit('Test message')
72
76
 
73
77
        tof = StringIO()
74
78
        revs =[]
83
87
                           '  hello.c\n'])
84
88
 
85
89
        self.build_tree(['more.c'])
86
 
        b.working_tree().add('more.c')
87
 
        b.working_tree().commit('Another test message')
 
90
        wt.add('more.c')
 
91
        wt.commit('Another test message')
88
92
        
89
93
        tof = StringIO()
90
94
        revs.append(RevisionSpec(1))
108
112
    def test_pending(self):
109
113
        """Pending merges display works, including Unicode"""
110
114
        mkdir("./branch")
111
 
        b = Branch.initialize('./branch')
112
 
        b.working_tree().commit("Empty commit 1")
 
115
        wt = WorkingTree.create_standalone('branch')
 
116
        b = wt.branch
 
117
        wt.commit("Empty commit 1")
113
118
        b_2 = b.clone('./copy')
114
 
        b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
 
119
        wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
115
120
        merge(["./branch", -1], [None, None], this_dir = './copy')
116
121
        message = self.status_string(b_2)
117
122
        self.assert_(message.startswith("pending merges:\n"))
128
133
 
129
134
    def test_branch_status_specific_files(self): 
130
135
        """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'.')
 
136
        wt = WorkingTree.create_standalone('.')
 
137
        b = wt.branch
136
138
 
137
139
        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')
 
140
        wt.add('directory')
 
141
        wt.add('test.c')
 
142
        wt.commit('testing')
141
143
        
142
144
        tof = StringIO()
143
145
        show_status(b, to_file=tof)