~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:
23
23
 
24
24
from bzrlib.selftest import TestCaseInTempDir
25
25
from bzrlib.revisionspec import RevisionSpec
 
26
from bzrlib.merge import merge
 
27
from cStringIO import StringIO
 
28
from bzrlib.status import show_status
 
29
from bzrlib.branch import Branch
 
30
from os import mkdir
 
31
from bzrlib.clone import copy_branch
26
32
 
27
33
class BranchStatus(TestCaseInTempDir):
28
34
    
41
47
 
42
48
        tof = StringIO()
43
49
        self.build_tree(['hello.c', 'bye.c'])
44
 
        b.add_pending_merge('pending@pending-0-0')
 
50
        b.working_tree().add_pending_merge('pending@pending-0-0')
45
51
        show_status(b, to_file=tof)
46
52
        tof.seek(0)
47
53
        self.assertEquals(tof.readlines(),
54
60
 
55
61
    def test_branch_status_revisions(self):
56
62
        """Tests branch status with revisions"""
57
 
        from cStringIO import StringIO
58
 
        from bzrlib.status import show_status
59
 
        from bzrlib.branch import Branch
60
63
        
61
64
        b = Branch.initialize('.')
62
65
 
64
67
        self.build_tree(['hello.c', 'bye.c'])
65
68
        b.add('hello.c')
66
69
        b.add('bye.c')
67
 
        b.commit('Test message')
 
70
        b.working_tree().commit('Test message')
68
71
 
69
72
        tof = StringIO()
70
73
        revs =[]
80
83
 
81
84
        self.build_tree(['more.c'])
82
85
        b.add('more.c')
83
 
        b.commit('Another test message')
 
86
        b.working_tree().commit('Another test message')
84
87
        
85
88
        tof = StringIO()
86
89
        revs.append(RevisionSpec(1))
93
96
                           '  bye.c\n',
94
97
                           '  hello.c\n'])
95
98
 
 
99
    def status_string(self, branch):
 
100
        tof = StringIO()
 
101
        show_status(branch, to_file=tof)
 
102
        tof.seek(0)
 
103
        return tof.getvalue()
 
104
 
 
105
    def test_pending(self):
 
106
        """Pending merges display works"""
 
107
        mkdir("./branch")
 
108
        b = Branch.initialize('./branch')
 
109
        b.working_tree().commit("Empty commit 1")
 
110
        b_2 = copy_branch(b, './copy')
 
111
        b.working_tree().commit("Empty commit 2")
 
112
        merge(["./branch", -1], [None, None], this_dir = './copy')
 
113
        message = self.status_string(b_2)
 
114
        self.assert_(message.startswith("pending merges:\n"))
 
115
        self.assert_(message.endswith("Empty commit 2\n")) 
 
116
        b_2.working_tree().commit("merged")
 
117
        # must be long to make sure we see elipsis at the end
 
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")
 
120
        merge(["./branch", -1], [None, None], this_dir = './copy')
 
121
        message = self.status_string(b_2)
 
122
        self.assert_(message.startswith("pending merges:\n"))
 
123
        self.assert_("Empty commit 3" in message)
 
124
        self.assert_(message.endswith("...\n")) 
 
125
 
96
126
    def test_branch_status_specific_files(self): 
97
127
        """Tests branch status with given specific files"""
98
128
        from cStringIO import StringIO
104
134
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
105
135
        b.add('directory')
106
136
        b.add('test.c')
107
 
        b.commit('testing')
 
137
        b.working_tree().commit('testing')
108
138
        
109
139
        tof = StringIO()
110
140
        show_status(b, to_file=tof)