/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Lukáš Lalinsky
  • Date: 2007-08-16 13:15:33 UTC
  • mto: (2755.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2757.
  • Revision ID: lalinsky@gmail.com-20070816131533-z6q24zlopxgys5vd
Replace the committer with the author in log, the committer is displayed only in the long format and only if it's different from the author.

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
    b.nick='test'
199
199
    open('a', 'wb').write('hello moto\n')
200
200
    wt.add('a')
201
 
    wt.commit('simple log message', rev_id='a1'
202
 
            , timestamp=1132586655.459960938, timezone=-6*3600
203
 
            , committer='Joe Foo <joe@foo.com>')
 
201
    wt.commit('simple log message', rev_id='a1',
 
202
              timestamp=1132586655.459960938, timezone=-6*3600,
 
203
              committer='Joe Foo <joe@foo.com>')
204
204
    open('b', 'wb').write('goodbye\n')
205
205
    wt.add('b')
206
 
    wt.commit('multiline\nlog\nmessage\n', rev_id='a2'
207
 
            , timestamp=1132586842.411175966, timezone=-6*3600
208
 
            , committer='Joe Foo <joe@foo.com>')
 
206
    wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
 
207
              timestamp=1132586842.411175966, timezone=-6*3600,
 
208
              committer='Joe Foo <joe@foo.com>',
 
209
              author='Joe Bar <joe@bar.com>')
209
210
 
210
211
    open('c', 'wb').write('just another manic monday\n')
211
212
    wt.add('c')
212
 
    wt.commit('single line with trailing newline\n', rev_id='a3'
213
 
            , timestamp=1132587176.835228920, timezone=-6*3600
214
 
            , committer = 'Joe Foo <joe@foo.com>')
 
213
    wt.commit('single line with trailing newline\n', rev_id='a3',
 
214
              timestamp=1132587176.835228920, timezone=-6*3600,
 
215
              committer = 'Joe Foo <joe@foo.com>')
215
216
    return b
216
217
 
217
218
 
227
228
    3 Joe Foo\t2005-11-21
228
229
      single line with trailing newline
229
230
 
230
 
    2 Joe Foo\t2005-11-21
 
231
    2 Joe Bar\t2005-11-21
231
232
      multiline
232
233
      log
233
234
      message
242
243
 
243
244
    def normalize_log(self,log):
244
245
        """Replaces the variable lines of logs with fixed lines"""
245
 
        committer = 'committer: Lorem Ipsum <test@example.com>'
 
246
        author = 'author: Lorem Ipsum <test@example.com>'
 
247
        committer = 'committer: Lorem Ipsum 2 <test2@example.com>'
246
248
        lines = log.splitlines(True)
247
249
        for idx,line in enumerate(lines):
248
250
            stripped_line = line.lstrip()
249
251
            indent = ' ' * (len(line) - len(stripped_line))
250
 
            if stripped_line.startswith('committer:'):
 
252
            if stripped_line.startswith('author:'):
 
253
                lines[idx] = indent + author + '\n'
 
254
            elif stripped_line.startswith('committer:'):
251
255
                lines[idx] = indent + committer + '\n'
252
 
            if stripped_line.startswith('timestamp:'):
 
256
            elif stripped_line.startswith('timestamp:'):
253
257
                lines[idx] = indent + 'timestamp: Just now\n'
254
258
        return ''.join(lines)
255
259
 
277
281
        self.assertEqualDiff(log_contents, '''\
278
282
------------------------------------------------------------
279
283
revno: 1
280
 
committer: Lorem Ipsum <test@example.com>
 
284
author: Lorem Ipsum <test@example.com>
281
285
branch nick: test_verbose_log
282
286
timestamp: Wed 2005-11-23 12:08:27 +1000
283
287
message:
308
312
        self.assertEqualDiff("""\
309
313
------------------------------------------------------------
310
314
revno: 2
311
 
committer: Lorem Ipsum <test@example.com>
 
315
author: Lorem Ipsum <test@example.com>
312
316
branch nick: parent
313
317
timestamp: Just now
314
318
message:
315
319
  merge branch 1
316
320
    ------------------------------------------------------------
317
321
    revno: 1.1.2
318
 
    committer: Lorem Ipsum <test@example.com>
 
322
    author: Lorem Ipsum <test@example.com>
319
323
    branch nick: child
320
324
    timestamp: Just now
321
325
    message:
322
326
      merge branch 2
323
327
        ------------------------------------------------------------
324
328
        revno: 1.1.1.1.1
325
 
        committer: Lorem Ipsum <test@example.com>
 
329
        author: Lorem Ipsum <test@example.com>
326
330
        branch nick: smallerchild
327
331
        timestamp: Just now
328
332
        message:
329
333
          branch 2
330
334
    ------------------------------------------------------------
331
335
    revno: 1.1.1
332
 
    committer: Lorem Ipsum <test@example.com>
 
336
    author: Lorem Ipsum <test@example.com>
333
337
    branch nick: child
334
338
    timestamp: Just now
335
339
    message:
336
340
      branch 1
337
341
------------------------------------------------------------
338
342
revno: 1
339
 
committer: Lorem Ipsum <test@example.com>
 
343
author: Lorem Ipsum <test@example.com>
340
344
branch nick: parent
341
345
timestamp: Just now
342
346
message:
364
368
        self.assertEqualDiff("""\
365
369
------------------------------------------------------------
366
370
revno: 2
367
 
committer: Lorem Ipsum <test@example.com>
 
371
author: Lorem Ipsum <test@example.com>
368
372
branch nick: parent
369
373
timestamp: Just now
370
374
message:
375
379
  f2
376
380
    ------------------------------------------------------------
377
381
    revno: 1.1.1
378
 
    committer: Lorem Ipsum <test@example.com>
 
382
    author: Lorem Ipsum <test@example.com>
379
383
    branch nick: child
380
384
    timestamp: Just now
381
385
    message:
386
390
      f2
387
391
------------------------------------------------------------
388
392
revno: 1
389
 
committer: Lorem Ipsum <test@example.com>
 
393
author: Lorem Ipsum <test@example.com>
390
394
branch nick: parent
391
395
timestamp: Just now
392
396
message:
405
409
        self.assertEqualDiff(sio.getvalue(), """\
406
410
------------------------------------------------------------
407
411
revno: 3
408
 
committer: Joe Foo <joe@foo.com>
 
412
author: Joe Foo <joe@foo.com>
409
413
branch nick: test
410
414
timestamp: Mon 2005-11-21 09:32:56 -0600
411
415
message:
412
416
  single line with trailing newline
413
417
------------------------------------------------------------
414
418
revno: 2
 
419
author: Joe Bar <joe@bar.com>
415
420
committer: Joe Foo <joe@foo.com>
416
421
branch nick: test
417
422
timestamp: Mon 2005-11-21 09:27:22 -0600
421
426
  message
422
427
------------------------------------------------------------
423
428
revno: 1
424
 
committer: Joe Foo <joe@foo.com>
 
429
author: Joe Foo <joe@foo.com>
425
430
branch nick: test
426
431
timestamp: Mon 2005-11-21 09:24:15 -0600
427
432
message:
428
433
  simple log message
429
434
""")
430
435
 
431
 
    def test_author_in_log(self):
432
 
        """Log includes the author name if it's set in
433
 
        the revision properties
 
436
    def test_committer_in_log(self):
 
437
        """Log includes the committer's name if it's
 
438
        different from the author.
434
439
        """
435
440
        wt = self.make_branch_and_tree('.')
436
441
        b = wt.branch
442
447
                  timezone=36000,
443
448
                  committer='Lorem Ipsum <test@example.com>',
444
449
                  author='John Doe <jdoe@example.com>')
 
450
        wt.commit(message='foo',
 
451
                  timestamp=1132712707,
 
452
                  timezone=36000,
 
453
                  committer='Lorem Ipsum <test@example.com>',
 
454
                  author='Lorem Ipsum <test@example.com>')
445
455
        sio = StringIO()
446
456
        formatter = LongLogFormatter(to_file=sio)
447
457
        show_log(b, formatter)
448
458
        self.assertEqualDiff(sio.getvalue(), '''\
449
459
------------------------------------------------------------
 
460
revno: 2
 
461
author: Lorem Ipsum <test@example.com>
 
462
branch nick: test_author_log
 
463
timestamp: Wed 2005-11-23 12:25:07 +1000
 
464
message:
 
465
  foo
 
466
------------------------------------------------------------
450
467
revno: 1
451
 
committer: Lorem Ipsum <test@example.com>
452
468
author: John Doe <jdoe@example.com>
 
469
committer: Lorem Ipsum <test@example.com>
453
470
branch nick: test_author_log
454
471
timestamp: Wed 2005-11-23 12:08:27 +1000
455
472
message:
521
538
        show_log(b, lf)
522
539
        self.assertEqualDiff(sio.getvalue(), """\
523
540
3: Joe Foo 2005-11-21 single line with trailing newline
524
 
2: Joe Foo 2005-11-21 multiline
 
541
2: Joe Bar 2005-11-21 multiline
525
542
1: Joe Foo 2005-11-21 simple log message
526
543
""")
527
544