50
50
self.logs.append(revision)
53
class SimpleLogTest(TestCaseWithTransport):
53
class TestShowLog(TestCaseWithTransport):
55
55
def checkDelta(self, delta, **kw):
56
56
"""Check the filenames touched by a delta are as expected."""
57
57
for n in 'added', 'removed', 'renamed', 'modified', 'unchanged':
58
58
expected = kw.get(n, [])
60
# tests are written with unix paths; fix them up for windows
62
# expected = [x.replace('/', os.sep) for x in expected]
64
59
# strip out only the path components
65
60
got = [x[0] for x in getattr(delta, n)]
66
61
self.assertEquals(expected, got)
158
153
self.log("escaped commit message: %r", committed_msg)
159
154
self.assert_(msg == committed_msg)
156
def test_deltas_in_merge_revisions(self):
157
"""Check deltas created for both mainline and merge revisions"""
158
eq = self.assertEquals
159
wt = self.make_branch_and_tree('parent')
160
self.build_tree(['parent/file1', 'parent/file2', 'parent/file3'])
163
wt.commit(message='add file1 and file2')
164
self.run_bzr('branch', 'parent', 'child')
165
os.unlink('child/file1')
166
print >> file('child/file2', 'wb'), 'hello'
167
self.run_bzr('commit', '-m', 'remove file1 and modify file2', 'child')
169
self.run_bzr('merge', '../child')
170
wt.commit('merge child branch')
174
lf.supports_merge_revisions = True
175
show_log(b, lf, verbose=True)
177
logentry = lf.logs[0]
178
eq(logentry.revno, '2')
179
eq(logentry.rev.message, 'merge child branch')
181
self.checkDelta(d, removed=['file1'], modified=['file2'])
182
logentry = lf.logs[1]
183
eq(logentry.revno, '1.1.1')
184
eq(logentry.rev.message, 'remove file1 and modify file2')
186
self.checkDelta(d, removed=['file1'], modified=['file2'])
187
logentry = lf.logs[2]
188
eq(logentry.revno, '1')
189
eq(logentry.rev.message, 'add file1 and file2')
191
self.checkDelta(d, added=['file1', 'file2'])
194
def make_commits_with_trailing_newlines(wt):
195
"""Helper method for LogFormatter tests"""
198
open('a', 'wb').write('hello moto\n')
200
wt.commit('simple log message', rev_id='a1'
201
, timestamp=1132586655.459960938, timezone=-6*3600
202
, committer='Joe Foo <joe@foo.com>')
203
open('b', 'wb').write('goodbye\n')
205
wt.commit('multiline\nlog\nmessage\n', rev_id='a2'
206
, timestamp=1132586842.411175966, timezone=-6*3600
207
, committer='Joe Foo <joe@foo.com>')
209
open('c', 'wb').write('just another manic monday\n')
211
wt.commit('single line with trailing newline\n', rev_id='a3'
212
, timestamp=1132587176.835228920, timezone=-6*3600
213
, committer = 'Joe Foo <joe@foo.com>')
217
class TestShortLogFormatter(TestCaseWithTransport):
161
219
def test_trailing_newlines(self):
162
220
wt = self.make_branch_and_tree('.')
165
open('a', 'wb').write('hello moto\n')
167
wt.commit('simple log message', rev_id='a1'
168
, timestamp=1132586655.459960938, timezone=-6*3600
169
, committer='Joe Foo <joe@foo.com>')
170
open('b', 'wb').write('goodbye\n')
172
wt.commit('multiline\nlog\nmessage\n', rev_id='a2'
173
, timestamp=1132586842.411175966, timezone=-6*3600
174
, committer='Joe Foo <joe@foo.com>')
176
open('c', 'wb').write('just another manic monday\n')
178
wt.commit('single line with trailing newline\n', rev_id='a3'
179
, timestamp=1132587176.835228920, timezone=-6*3600
180
, committer = 'Joe Foo <joe@foo.com>')
221
b = make_commits_with_trailing_newlines(wt)
183
223
lf = ShortLogFormatter(to_file=sio)
200
lf = LongLogFormatter(to_file=sio)
202
self.assertEquals(sio.getvalue(), """\
203
------------------------------------------------------------
205
committer: Joe Foo <joe@foo.com>
207
timestamp: Mon 2005-11-21 09:32:56 -0600
209
single line with trailing newline
210
------------------------------------------------------------
212
committer: Joe Foo <joe@foo.com>
214
timestamp: Mon 2005-11-21 09:27:22 -0600
219
------------------------------------------------------------
221
committer: Joe Foo <joe@foo.com>
223
timestamp: Mon 2005-11-21 09:24:15 -0600
240
class TestLongLogFormatter(TestCaseWithTransport):
242
def normalize_log(self,log):
243
"""Replaces the variable lines of logs with fixed lines"""
244
committer = 'committer: Lorem Ipsum <test@example.com>'
245
lines = log.splitlines(True)
246
for idx,line in enumerate(lines):
247
stripped_line = line.lstrip()
248
indent = ' ' * (len(line) - len(stripped_line))
249
if stripped_line.startswith('committer:'):
250
lines[idx] = indent + committer + '\n'
251
if stripped_line.startswith('timestamp:'):
252
lines[idx] = indent + 'timestamp: Just now\n'
253
return ''.join(lines)
228
255
def test_verbose_log(self):
229
256
"""Verbose log includes changed files
288
def test_merges_are_indented_by_level(self):
289
wt = self.make_branch_and_tree('parent')
290
wt.commit('first post')
291
self.run_bzr('branch', 'parent', 'child')
292
self.run_bzr('commit', '-m', 'branch 1', '--unchanged', 'child')
293
self.run_bzr('branch', 'child', 'smallerchild')
294
self.run_bzr('commit', '-m', 'branch 2', '--unchanged', 'smallerchild')
296
self.run_bzr('merge', '../smallerchild')
297
self.run_bzr('commit', '-m', 'merge branch 2')
298
os.chdir('../parent')
299
self.run_bzr('merge', '../child')
300
wt.commit('merge branch 1')
303
lf = LongLogFormatter(to_file=sio)
304
show_log(b, lf, verbose=True)
305
log = self.normalize_log(sio.getvalue())
306
self.assertEqualDiff("""\
307
------------------------------------------------------------
309
committer: Lorem Ipsum <test@example.com>
314
------------------------------------------------------------
316
committer: Lorem Ipsum <test@example.com>
321
------------------------------------------------------------
323
committer: Lorem Ipsum <test@example.com>
324
branch nick: smallerchild
328
------------------------------------------------------------
330
committer: Lorem Ipsum <test@example.com>
335
------------------------------------------------------------
337
committer: Lorem Ipsum <test@example.com>
344
def test_verbose_merge_revisions_contain_deltas(self):
345
wt = self.make_branch_and_tree('parent')
346
self.build_tree(['parent/f1', 'parent/f2'])
348
wt.commit('first post')
349
self.run_bzr('branch', 'parent', 'child')
350
os.unlink('child/f1')
351
print >> file('child/f2', 'wb'), 'hello'
352
self.run_bzr('commit', '-m', 'removed f1 and modified f2', 'child')
354
self.run_bzr('merge', '../child')
355
wt.commit('merge branch 1')
358
lf = LongLogFormatter(to_file=sio)
359
show_log(b, lf, verbose=True)
360
log = self.normalize_log(sio.getvalue())
361
self.assertEqualDiff("""\
362
------------------------------------------------------------
364
committer: Lorem Ipsum <test@example.com>
373
------------------------------------------------------------
375
committer: Lorem Ipsum <test@example.com>
379
removed f1 and modified f2
384
------------------------------------------------------------
386
committer: Lorem Ipsum <test@example.com>
396
def test_trailing_newlines(self):
397
wt = self.make_branch_and_tree('.')
398
b = make_commits_with_trailing_newlines(wt)
400
lf = LongLogFormatter(to_file=sio)
402
self.assertEqualDiff(sio.getvalue(), """\
403
------------------------------------------------------------
405
committer: Joe Foo <joe@foo.com>
407
timestamp: Mon 2005-11-21 09:32:56 -0600
409
single line with trailing newline
410
------------------------------------------------------------
412
committer: Joe Foo <joe@foo.com>
414
timestamp: Mon 2005-11-21 09:27:22 -0600
419
------------------------------------------------------------
421
committer: Joe Foo <joe@foo.com>
423
timestamp: Mon 2005-11-21 09:24:15 -0600
429
class TestLineLogFormatter(TestCaseWithTransport):
261
431
def test_line_log(self):
262
432
"""Line log should show revno
484
def test_trailing_newlines(self):
485
wt = self.make_branch_and_tree('.')
486
b = make_commits_with_trailing_newlines(wt)
488
lf = LineLogFormatter(to_file=sio)
490
self.assertEqualDiff(sio.getvalue(), """\
491
3: Joe Foo 2005-11-21 single line with trailing newline
492
2: Joe Foo 2005-11-21 multiline
493
1: Joe Foo 2005-11-21 simple log message
497
class TestGetViewRevisions(TestCaseWithTransport):
314
499
def make_tree_with_commits(self):
315
500
"""Create a tree with well-known revision ids"""
316
501
wt = self.make_branch_and_tree('tree1')