18
18
from cStringIO import StringIO
20
20
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
21
from bzrlib.log import LogFormatter, show_log, LongLogFormatter
21
from bzrlib.log import LogFormatter, show_log, LongLogFormatter, ShortLogFormatter
22
22
from bzrlib.branch import Branch
23
23
from bzrlib.errors import InvalidRevisionNumber
160
160
self.log("escaped commit message: %r", committed_msg)
161
161
self.assert_(msg != committed_msg)
162
162
self.assert_(len(committed_msg) > len(msg))
164
def test_trailing_newlines(self):
165
b = Branch.initialize('.')
167
wt = b.working_tree()
168
open('a', 'wb').write('hello moto\n')
170
wt.commit('simple log message', rev_id='a1'
171
, timestamp=1132586655.459960938, timezone=-6*3600
172
, committer='Joe Foo <joe@foo.com>')
173
open('b', 'wb').write('goodbye\n')
175
wt.commit('multiline\nlog\nmessage\n', rev_id='a2'
176
, timestamp=1132586842.411175966, timezone=-6*3600
177
, committer='Joe Foo <joe@foo.com>')
179
open('c', 'wb').write('just another manic monday\n')
181
wt.commit('single line with trailing newline\n', rev_id='a3'
182
, timestamp=1132587176.835228920, timezone=-6*3600
183
, committer = 'Joe Foo <joe@foo.com>')
186
lf = ShortLogFormatter(to_file=sio)
188
self.assertEquals(sio.getvalue(), """\
189
3 Joe Foo\t2005-11-21
190
single line with trailing newline
192
2 Joe Foo\t2005-11-21
197
1 Joe Foo\t2005-11-21
203
lf = LongLogFormatter(to_file=sio)
205
self.assertEquals(sio.getvalue(), """\
206
------------------------------------------------------------
208
committer: Joe Foo <joe@foo.com>
210
timestamp: Mon 2005-11-21 09:32:56 -0600
212
single line with trailing newline
213
------------------------------------------------------------
215
committer: Joe Foo <joe@foo.com>
217
timestamp: Mon 2005-11-21 09:27:22 -0600
222
------------------------------------------------------------
224
committer: Joe Foo <joe@foo.com>
226
timestamp: Mon 2005-11-21 09:24:15 -0600