~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Move working tree initialisation out from  Branch.initialize, deprecated Branch.initialize to Branch.create.

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