~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Martin Pool
  • Date: 2010-01-15 04:31:19 UTC
  • mto: This revision was merged to the branch mainline in revision 5019.
  • Revision ID: mbp@sourcefrog.net-20100115043119-zvlyd5l787ddp6uh
Pull out pbs and ProgressPhases stored in object state; just use them in single functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    registry,
24
24
    revision,
25
25
    revisionspec,
26
 
    symbol_versioning,
27
26
    tests,
28
27
    )
29
28
 
30
29
 
31
 
class TestLogMixin(object):
32
 
 
33
 
    def wt_commit(self, wt, message, **kwargs):
34
 
        """Use some mostly fixed values for commits to simplify tests.
35
 
 
36
 
        Tests can use this function to get some commit attributes. The time
37
 
        stamp is incremented at each commit.
38
 
        """
39
 
        if getattr(self, 'timestamp', None) is None:
40
 
            self.timestamp = 1132617600 # Mon 2005-11-22 00:00:00 +0000
41
 
        else:
42
 
            self.timestamp += 1 # 1 second between each commit
43
 
        kwargs.setdefault('timestamp', self.timestamp)
44
 
        kwargs.setdefault('timezone', 0) # UTC
45
 
        kwargs.setdefault('committer', 'Joe Foo <joe@foo.com>')
46
 
 
47
 
        return wt.commit(message, **kwargs)
48
 
 
49
 
 
50
 
class TestCaseForLogFormatter(tests.TestCaseWithTransport, TestLogMixin):
 
30
class TestCaseForLogFormatter(tests.TestCaseWithTransport):
51
31
 
52
32
    def setUp(self):
53
33
        super(TestCaseForLogFormatter, self).setUp()
61
41
        self.addCleanup(restore)
62
42
 
63
43
    def assertFormatterResult(self, result, branch, formatter_class,
64
 
                              formatter_kwargs=None, show_log_kwargs=None):
 
44
                              formatter_kwargs=None, show_log_kwargs=None,
 
45
                              normalize=False):
65
46
        logfile = self.make_utf8_encoded_stringio()
66
47
        if formatter_kwargs is None:
67
48
            formatter_kwargs = {}
69
50
        if show_log_kwargs is None:
70
51
            show_log_kwargs = {}
71
52
        log.show_log(branch, formatter, **show_log_kwargs)
72
 
        self.assertEqualDiff(result, logfile.getvalue())
 
53
        log_content = logfile.getvalue()
 
54
        if normalize:
 
55
            log_content = normalize_log(log_content)
 
56
        self.assertEqualDiff(result, log_content)
73
57
 
74
58
    def make_standard_commit(self, branch_nick, **kwargs):
75
59
        wt = self.make_branch_and_tree('.')
78
62
        self.build_tree(['a'])
79
63
        wt.add(['a'])
80
64
        wt.branch.nick = branch_nick
 
65
        kwargs = dict(kwargs)
 
66
        kwargs.setdefault('message', 'add a')
 
67
        kwargs.setdefault('timestamp', 1132711707)
 
68
        kwargs.setdefault('timezone', 36000)
81
69
        kwargs.setdefault('committer', 'Lorem Ipsum <test@example.com>')
82
70
        kwargs.setdefault('authors', ['John Doe <jdoe@example.com>'])
83
 
        self.wt_commit(wt, 'add a', **kwargs)
 
71
        wt.commit(**kwargs)
84
72
        return wt
85
73
 
86
 
    def make_commits_with_trailing_newlines(self, wt):
87
 
        """Helper method for LogFormatter tests"""
88
 
        b = wt.branch
89
 
        b.nick = 'test'
90
 
        self.build_tree_contents([('a', 'hello moto\n')])
91
 
        self.wt_commit(wt, 'simple log message', rev_id='a1')
92
 
        self.build_tree_contents([('b', 'goodbye\n')])
93
 
        wt.add('b')
94
 
        self.wt_commit(wt, 'multiline\nlog\nmessage\n', rev_id='a2')
95
 
 
96
 
        self.build_tree_contents([('c', 'just another manic monday\n')])
97
 
        wt.add('c')
98
 
        self.wt_commit(wt, 'single line with trailing newline\n', rev_id='a3')
99
 
        return b
100
 
 
101
74
    def _prepare_tree_with_merges(self, with_tags=False):
102
75
        wt = self.make_branch_and_memory_tree('.')
103
76
        wt.lock_write()
104
77
        self.addCleanup(wt.unlock)
105
78
        wt.add('')
106
 
        self.wt_commit(wt, 'rev-1', rev_id='rev-1')
107
 
        self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
 
79
        wt.commit('rev-1', rev_id='rev-1',
 
80
                  timestamp=1132586655, timezone=36000,
 
81
                  committer='Joe Foo <joe@foo.com>')
 
82
        wt.commit('rev-merged', rev_id='rev-2a',
 
83
                  timestamp=1132586700, timezone=36000,
 
84
                  committer='Joe Foo <joe@foo.com>')
108
85
        wt.set_parent_ids(['rev-1', 'rev-2a'])
109
86
        wt.branch.set_last_revision_info(1, 'rev-1')
110
 
        self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
 
87
        wt.commit('rev-2', rev_id='rev-2b',
 
88
                  timestamp=1132586800, timezone=36000,
 
89
                  committer='Joe Foo <joe@foo.com>')
111
90
        if with_tags:
112
91
            branch = wt.branch
113
92
            branch.tags.set_tag('v0.2', 'rev-2b')
114
 
            self.wt_commit(wt, 'rev-3', rev_id='rev-3')
 
93
            wt.commit('rev-3', rev_id='rev-3',
 
94
                      timestamp=1132586900, timezone=36000,
 
95
                      committer='Jane Foo <jane@foo.com>')
115
96
            branch.tags.set_tag('v1.0rc1', 'rev-3')
116
97
            branch.tags.set_tag('v1.0', 'rev-3')
117
98
        return wt
118
99
 
 
100
        
 
101
 
 
102
 
119
103
class LogCatcher(log.LogFormatter):
120
104
    """Pull log messages into a list rather than displaying them.
121
105
 
124
108
    being dependent on the formatting.
125
109
    """
126
110
 
127
 
    supports_merge_revisions = True
128
111
    supports_delta = True
129
 
    supports_diff = True
130
 
    preferred_levels = 0
131
112
 
132
 
    def __init__(self, *args, **kwargs):
133
 
        kwargs.update(dict(to_file=None))
134
 
        super(LogCatcher, self).__init__(*args, **kwargs)
 
113
    def __init__(self):
 
114
        super(LogCatcher, self).__init__(to_file=None)
135
115
        self.revisions = []
136
116
 
137
117
    def log_revision(self, revision):
280
260
        self.checkDelta(logentry.delta, added=['file1', 'file2'])
281
261
 
282
262
 
 
263
def make_commits_with_trailing_newlines(wt):
 
264
    """Helper method for LogFormatter tests"""
 
265
    b = wt.branch
 
266
    b.nick='test'
 
267
    open('a', 'wb').write('hello moto\n')
 
268
    wt.add('a')
 
269
    wt.commit('simple log message', rev_id='a1',
 
270
              timestamp=1132586655.459960938, timezone=-6*3600,
 
271
              committer='Joe Foo <joe@foo.com>')
 
272
    open('b', 'wb').write('goodbye\n')
 
273
    wt.add('b')
 
274
    wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
 
275
              timestamp=1132586842.411175966, timezone=-6*3600,
 
276
              committer='Joe Foo <joe@foo.com>',
 
277
              authors=['Joe Bar <joe@bar.com>'])
 
278
 
 
279
    open('c', 'wb').write('just another manic monday\n')
 
280
    wt.add('c')
 
281
    wt.commit('single line with trailing newline\n', rev_id='a3',
 
282
              timestamp=1132587176.835228920, timezone=-6*3600,
 
283
              committer = 'Joe Foo <joe@foo.com>')
 
284
    return b
 
285
 
 
286
 
 
287
def normalize_log(log):
 
288
    """Replaces the variable lines of logs with fixed lines"""
 
289
    author = 'author: Dolor Sit <test@example.com>'
 
290
    committer = 'committer: Lorem Ipsum <test@example.com>'
 
291
    lines = log.splitlines(True)
 
292
    for idx,line in enumerate(lines):
 
293
        stripped_line = line.lstrip()
 
294
        indent = ' ' * (len(line) - len(stripped_line))
 
295
        if stripped_line.startswith('author:'):
 
296
            lines[idx] = indent + author + '\n'
 
297
        elif stripped_line.startswith('committer:'):
 
298
            lines[idx] = indent + committer + '\n'
 
299
        elif stripped_line.startswith('timestamp:'):
 
300
            lines[idx] = indent + 'timestamp: Just now\n'
 
301
    return ''.join(lines)
 
302
 
 
303
 
283
304
class TestShortLogFormatter(TestCaseForLogFormatter):
284
305
 
285
306
    def test_trailing_newlines(self):
286
307
        wt = self.make_branch_and_tree('.')
287
 
        b = self.make_commits_with_trailing_newlines(wt)
 
308
        b = make_commits_with_trailing_newlines(wt)
288
309
        self.assertFormatterResult("""\
289
 
    3 Joe Foo\t2005-11-22
 
310
    3 Joe Foo\t2005-11-21
290
311
      single line with trailing newline
291
312
 
292
 
    2 Joe Foo\t2005-11-22
 
313
    2 Joe Bar\t2005-11-21
293
314
      multiline
294
315
      log
295
316
      message
296
317
 
297
 
    1 Joe Foo\t2005-11-22
 
318
    1 Joe Foo\t2005-11-21
298
319
      simple log message
299
320
 
300
321
""",
327
348
            formatter_kwargs=dict(show_advice=True))
328
349
 
329
350
    def test_short_log_with_merges_and_range(self):
330
 
        wt = self._prepare_tree_with_merges()
331
 
        self.wt_commit(wt, 'rev-3a', rev_id='rev-3a')
 
351
        wt = self.make_branch_and_memory_tree('.')
 
352
        wt.lock_write()
 
353
        self.addCleanup(wt.unlock)
 
354
        wt.add('')
 
355
        wt.commit('rev-1', rev_id='rev-1',
 
356
                  timestamp=1132586655, timezone=36000,
 
357
                  committer='Joe Foo <joe@foo.com>')
 
358
        wt.commit('rev-merged', rev_id='rev-2a',
 
359
                  timestamp=1132586700, timezone=36000,
 
360
                  committer='Joe Foo <joe@foo.com>')
 
361
        wt.branch.set_last_revision_info(1, 'rev-1')
 
362
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
363
        wt.commit('rev-2b', rev_id='rev-2b',
 
364
                  timestamp=1132586800, timezone=36000,
 
365
                  committer='Joe Foo <joe@foo.com>')
 
366
        wt.commit('rev-3a', rev_id='rev-3a',
 
367
                  timestamp=1132586800, timezone=36000,
 
368
                  committer='Joe Foo <joe@foo.com>')
332
369
        wt.branch.set_last_revision_info(2, 'rev-2b')
333
370
        wt.set_parent_ids(['rev-2b', 'rev-3a'])
334
 
        self.wt_commit(wt, 'rev-3b', rev_id='rev-3b')
 
371
        wt.commit('rev-3b', rev_id='rev-3b',
 
372
                  timestamp=1132586800, timezone=36000,
 
373
                  committer='Joe Foo <joe@foo.com>')
335
374
        self.assertFormatterResult("""\
336
375
    3 Joe Foo\t2005-11-22 [merge]
337
376
      rev-3b
338
377
 
339
378
    2 Joe Foo\t2005-11-22 [merge]
340
 
      rev-2
 
379
      rev-2b
341
380
 
342
381
""",
343
382
            wt.branch, log.ShortLogFormatter,
346
385
    def test_short_log_with_tags(self):
347
386
        wt = self._prepare_tree_with_merges(with_tags=True)
348
387
        self.assertFormatterResult("""\
349
 
    3 Joe Foo\t2005-11-22 {v1.0, v1.0rc1}
 
388
    3 Jane Foo\t2005-11-22 {v1.0, v1.0rc1}
350
389
      rev-3
351
390
 
352
391
    2 Joe Foo\t2005-11-22 {v0.2} [merge]
359
398
            wt.branch, log.ShortLogFormatter)
360
399
 
361
400
    def test_short_log_single_merge_revision(self):
362
 
        wt = self._prepare_tree_with_merges()
 
401
        wt = self.make_branch_and_memory_tree('.')
 
402
        wt.lock_write()
 
403
        self.addCleanup(wt.unlock)
 
404
        wt.add('')
 
405
        wt.commit('rev-1', rev_id='rev-1',
 
406
                  timestamp=1132586655, timezone=36000,
 
407
                  committer='Joe Foo <joe@foo.com>')
 
408
        wt.commit('rev-merged', rev_id='rev-2a',
 
409
                  timestamp=1132586700, timezone=36000,
 
410
                  committer='Joe Foo <joe@foo.com>')
 
411
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
412
        wt.branch.set_last_revision_info(1, 'rev-1')
 
413
        wt.commit('rev-2', rev_id='rev-2b',
 
414
                  timestamp=1132586800, timezone=36000,
 
415
                  committer='Joe Foo <joe@foo.com>')
363
416
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
364
417
        rev = revspec.in_history(wt.branch)
365
418
        self.assertFormatterResult("""\
374
427
class TestShortLogFormatterWithMergeRevisions(TestCaseForLogFormatter):
375
428
 
376
429
    def test_short_merge_revs_log_with_merges(self):
377
 
        wt = self._prepare_tree_with_merges()
 
430
        wt = self.make_branch_and_memory_tree('.')
 
431
        wt.lock_write()
 
432
        self.addCleanup(wt.unlock)
 
433
        wt.add('')
 
434
        wt.commit('rev-1', rev_id='rev-1',
 
435
                  timestamp=1132586655, timezone=36000,
 
436
                  committer='Joe Foo <joe@foo.com>')
 
437
        wt.commit('rev-merged', rev_id='rev-2a',
 
438
                  timestamp=1132586700, timezone=36000,
 
439
                  committer='Joe Foo <joe@foo.com>')
 
440
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
441
        wt.branch.set_last_revision_info(1, 'rev-1')
 
442
        wt.commit('rev-2', rev_id='rev-2b',
 
443
                  timestamp=1132586800, timezone=36000,
 
444
                  committer='Joe Foo <joe@foo.com>')
378
445
        # Note that the 1.1.1 indenting is in fact correct given that
379
446
        # the revision numbers are right justified within 5 characters
380
447
        # for mainline revnos and 9 characters for dotted revnos.
393
460
            formatter_kwargs=dict(levels=0))
394
461
 
395
462
    def test_short_merge_revs_log_single_merge_revision(self):
396
 
        wt = self._prepare_tree_with_merges()
 
463
        wt = self.make_branch_and_memory_tree('.')
 
464
        wt.lock_write()
 
465
        self.addCleanup(wt.unlock)
 
466
        wt.add('')
 
467
        wt.commit('rev-1', rev_id='rev-1',
 
468
                  timestamp=1132586655, timezone=36000,
 
469
                  committer='Joe Foo <joe@foo.com>')
 
470
        wt.commit('rev-merged', rev_id='rev-2a',
 
471
                  timestamp=1132586700, timezone=36000,
 
472
                  committer='Joe Foo <joe@foo.com>')
 
473
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
474
        wt.branch.set_last_revision_info(1, 'rev-1')
 
475
        wt.commit('rev-2', rev_id='rev-2b',
 
476
                  timestamp=1132586800, timezone=36000,
 
477
                  committer='Joe Foo <joe@foo.com>')
397
478
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
398
479
        rev = revspec.in_history(wt.branch)
399
480
        self.assertFormatterResult("""\
419
500
revno: 1
420
501
committer: Lorem Ipsum <test@example.com>
421
502
branch nick: test_verbose_log
422
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
503
timestamp: Wed 2005-11-23 12:08:27 +1000
423
504
message:
424
505
  add a
425
506
added:
430
511
 
431
512
    def test_merges_are_indented_by_level(self):
432
513
        wt = self.make_branch_and_tree('parent')
433
 
        self.wt_commit(wt, 'first post')
434
 
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
435
 
        self.wt_commit(child_wt, 'branch 1')
436
 
        smallerchild_wt = wt.bzrdir.sprout('smallerchild').open_workingtree()
437
 
        self.wt_commit(smallerchild_wt, 'branch 2')
438
 
        child_wt.merge_from_branch(smallerchild_wt.branch)
439
 
        self.wt_commit(child_wt, 'merge branch 2')
440
 
        wt.merge_from_branch(child_wt.branch)
441
 
        self.wt_commit(wt, 'merge branch 1')
 
514
        wt.commit('first post')
 
515
        self.run_bzr('branch parent child')
 
516
        self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child'])
 
517
        self.run_bzr('branch child smallerchild')
 
518
        self.run_bzr(['commit', '-m', 'branch 2', '--unchanged',
 
519
            'smallerchild'])
 
520
        os.chdir('child')
 
521
        self.run_bzr('merge ../smallerchild')
 
522
        self.run_bzr(['commit', '-m', 'merge branch 2'])
 
523
        os.chdir('../parent')
 
524
        self.run_bzr('merge ../child')
 
525
        wt.commit('merge branch 1')
442
526
        self.assertFormatterResult("""\
443
527
------------------------------------------------------------
444
528
revno: 2 [merge]
445
 
committer: Joe Foo <joe@foo.com>
 
529
committer: Lorem Ipsum <test@example.com>
446
530
branch nick: parent
447
 
timestamp: Tue 2005-11-22 00:00:04 +0000
 
531
timestamp: Just now
448
532
message:
449
533
  merge branch 1
450
534
    ------------------------------------------------------------
451
535
    revno: 1.1.2 [merge]
452
 
    committer: Joe Foo <joe@foo.com>
 
536
    committer: Lorem Ipsum <test@example.com>
453
537
    branch nick: child
454
 
    timestamp: Tue 2005-11-22 00:00:03 +0000
 
538
    timestamp: Just now
455
539
    message:
456
540
      merge branch 2
457
541
        ------------------------------------------------------------
458
542
        revno: 1.2.1
459
 
        committer: Joe Foo <joe@foo.com>
 
543
        committer: Lorem Ipsum <test@example.com>
460
544
        branch nick: smallerchild
461
 
        timestamp: Tue 2005-11-22 00:00:02 +0000
 
545
        timestamp: Just now
462
546
        message:
463
547
          branch 2
464
548
    ------------------------------------------------------------
465
549
    revno: 1.1.1
466
 
    committer: Joe Foo <joe@foo.com>
 
550
    committer: Lorem Ipsum <test@example.com>
467
551
    branch nick: child
468
 
    timestamp: Tue 2005-11-22 00:00:01 +0000
 
552
    timestamp: Just now
469
553
    message:
470
554
      branch 1
471
555
------------------------------------------------------------
472
556
revno: 1
473
 
committer: Joe Foo <joe@foo.com>
 
557
committer: Lorem Ipsum <test@example.com>
474
558
branch nick: parent
475
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
559
timestamp: Just now
476
560
message:
477
561
  first post
478
562
""",
479
563
            wt.branch, log.LongLogFormatter,
480
564
            formatter_kwargs=dict(levels=0),
481
 
            show_log_kwargs=dict(verbose=True))
 
565
            show_log_kwargs=dict(verbose=True),
 
566
            normalize=True)
482
567
 
483
568
    def test_verbose_merge_revisions_contain_deltas(self):
484
569
        wt = self.make_branch_and_tree('parent')
485
570
        self.build_tree(['parent/f1', 'parent/f2'])
486
571
        wt.add(['f1','f2'])
487
 
        self.wt_commit(wt, 'first post')
488
 
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
 
572
        wt.commit('first post')
 
573
        self.run_bzr('branch parent child')
489
574
        os.unlink('child/f1')
490
 
        self.build_tree_contents([('child/f2', 'hello\n')])
491
 
        self.wt_commit(child_wt, 'removed f1 and modified f2')
492
 
        wt.merge_from_branch(child_wt.branch)
493
 
        self.wt_commit(wt, 'merge branch 1')
 
575
        file('child/f2', 'wb').write('hello\n')
 
576
        self.run_bzr(['commit', '-m', 'removed f1 and modified f2',
 
577
            'child'])
 
578
        os.chdir('parent')
 
579
        self.run_bzr('merge ../child')
 
580
        wt.commit('merge branch 1')
494
581
        self.assertFormatterResult("""\
495
582
------------------------------------------------------------
496
583
revno: 2 [merge]
497
 
committer: Joe Foo <joe@foo.com>
 
584
committer: Lorem Ipsum <test@example.com>
498
585
branch nick: parent
499
 
timestamp: Tue 2005-11-22 00:00:02 +0000
 
586
timestamp: Just now
500
587
message:
501
588
  merge branch 1
502
589
removed:
505
592
  f2
506
593
    ------------------------------------------------------------
507
594
    revno: 1.1.1
508
 
    committer: Joe Foo <joe@foo.com>
 
595
    committer: Lorem Ipsum <test@example.com>
509
596
    branch nick: child
510
 
    timestamp: Tue 2005-11-22 00:00:01 +0000
 
597
    timestamp: Just now
511
598
    message:
512
599
      removed f1 and modified f2
513
600
    removed:
516
603
      f2
517
604
------------------------------------------------------------
518
605
revno: 1
519
 
committer: Joe Foo <joe@foo.com>
 
606
committer: Lorem Ipsum <test@example.com>
520
607
branch nick: parent
521
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
608
timestamp: Just now
522
609
message:
523
610
  first post
524
611
added:
527
614
""",
528
615
            wt.branch, log.LongLogFormatter,
529
616
            formatter_kwargs=dict(levels=0),
530
 
            show_log_kwargs=dict(verbose=True))
 
617
            show_log_kwargs=dict(verbose=True),
 
618
            normalize=True)
531
619
 
532
620
    def test_trailing_newlines(self):
533
621
        wt = self.make_branch_and_tree('.')
534
 
        b = self.make_commits_with_trailing_newlines(wt)
 
622
        b = make_commits_with_trailing_newlines(wt)
535
623
        self.assertFormatterResult("""\
536
624
------------------------------------------------------------
537
625
revno: 3
538
626
committer: Joe Foo <joe@foo.com>
539
627
branch nick: test
540
 
timestamp: Tue 2005-11-22 00:00:02 +0000
 
628
timestamp: Mon 2005-11-21 09:32:56 -0600
541
629
message:
542
630
  single line with trailing newline
543
631
------------------------------------------------------------
544
632
revno: 2
 
633
author: Joe Bar <joe@bar.com>
545
634
committer: Joe Foo <joe@foo.com>
546
635
branch nick: test
547
 
timestamp: Tue 2005-11-22 00:00:01 +0000
 
636
timestamp: Mon 2005-11-21 09:27:22 -0600
548
637
message:
549
638
  multiline
550
639
  log
553
642
revno: 1
554
643
committer: Joe Foo <joe@foo.com>
555
644
branch nick: test
556
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
645
timestamp: Mon 2005-11-21 09:24:15 -0600
557
646
message:
558
647
  simple log message
559
648
""",
572
661
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
573
662
committer: Lorem Ipsum <test@example.com>
574
663
branch nick: test_author_log
575
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
664
timestamp: Wed 2005-11-23 12:08:27 +1000
576
665
message:
577
666
  add a
578
667
""",
597
686
author: John Doe <jdoe@example.com>
598
687
committer: Lorem Ipsum <test@example.com>
599
688
branch nick: test_properties_in_log
600
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
689
timestamp: Wed 2005-11-23 12:08:27 +1000
601
690
message:
602
691
  add a
603
692
""",
615
704
            'trivial_custom_prop_handler',
616
705
            trivial_custom_prop_handler)
617
706
        self.assertFormatterResult("""\
618
 
    1 John Doe\t2005-11-22
 
707
    1 John Doe\t2005-11-23
619
708
      test_prop: test_value
620
709
      add a
621
710
 
672
761
revno: 1
673
762
committer: Lorem Ipsum <test@example.com>
674
763
branch nick: test_long_verbose_log
675
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
764
timestamp: Wed 2005-11-23 12:08:27 +1000
676
765
message:
677
766
  add a
678
767
added:
686
775
        wt = self.make_branch_and_tree('parent')
687
776
        self.build_tree(['parent/f1', 'parent/f2'])
688
777
        wt.add(['f1','f2'])
689
 
        self.wt_commit(wt, 'first post')
 
778
        wt.commit('first post')
690
779
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
691
780
        os.unlink('child/f1')
692
781
        self.build_tree_contents([('child/f2', 'hello\n')])
693
 
        self.wt_commit(child_wt, 'removed f1 and modified f2')
 
782
        child_wt.commit('removed f1 and modified f2')
694
783
        wt.merge_from_branch(child_wt.branch)
695
 
        self.wt_commit(wt, 'merge branch 1')
 
784
        wt.commit('merge branch 1')
696
785
        self.assertFormatterResult("""\
697
786
------------------------------------------------------------
698
787
revno: 2 [merge]
699
 
committer: Joe Foo <joe@foo.com>
 
788
committer: Lorem Ipsum <test@example.com>
700
789
branch nick: parent
701
 
timestamp: Tue 2005-11-22 00:00:02 +0000
 
790
timestamp: Just now
702
791
message:
703
792
  merge branch 1
704
793
removed:
707
796
  f2
708
797
------------------------------------------------------------
709
798
revno: 1
710
 
committer: Joe Foo <joe@foo.com>
 
799
committer: Lorem Ipsum <test@example.com>
711
800
branch nick: parent
712
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
801
timestamp: Just now
713
802
message:
714
803
  first post
715
804
added:
718
807
""",
719
808
            wt.branch, log.LongLogFormatter,
720
809
            formatter_kwargs=dict(levels=1),
721
 
            show_log_kwargs=dict(verbose=True))
 
810
            show_log_kwargs=dict(verbose=True),
 
811
            normalize=True)
722
812
 
723
813
    def test_long_trailing_newlines(self):
724
814
        wt = self.make_branch_and_tree('.')
725
 
        b = self.make_commits_with_trailing_newlines(wt)
 
815
        b = make_commits_with_trailing_newlines(wt)
726
816
        self.assertFormatterResult("""\
727
817
------------------------------------------------------------
728
818
revno: 3
729
819
committer: Joe Foo <joe@foo.com>
730
820
branch nick: test
731
 
timestamp: Tue 2005-11-22 00:00:02 +0000
 
821
timestamp: Mon 2005-11-21 09:32:56 -0600
732
822
message:
733
823
  single line with trailing newline
734
824
------------------------------------------------------------
735
825
revno: 2
 
826
author: Joe Bar <joe@bar.com>
736
827
committer: Joe Foo <joe@foo.com>
737
828
branch nick: test
738
 
timestamp: Tue 2005-11-22 00:00:01 +0000
 
829
timestamp: Mon 2005-11-21 09:27:22 -0600
739
830
message:
740
831
  multiline
741
832
  log
744
835
revno: 1
745
836
committer: Joe Foo <joe@foo.com>
746
837
branch nick: test
747
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
838
timestamp: Mon 2005-11-21 09:24:15 -0600
748
839
message:
749
840
  simple log message
750
841
""",
762
853
author: John Doe <jdoe@example.com>
763
854
committer: Lorem Ipsum <test@example.com>
764
855
branch nick: test_author_log
765
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
856
timestamp: Wed 2005-11-23 12:08:27 +1000
766
857
message:
767
858
  add a
768
859
""",
787
878
author: John Doe <jdoe@example.com>
788
879
committer: Lorem Ipsum <test@example.com>
789
880
branch nick: test_properties_in_log
790
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
881
timestamp: Wed 2005-11-23 12:08:27 +1000
791
882
message:
792
883
  add a
793
884
""",
806
897
                committer='Line-Log-Formatter Tester <test@line.log>',
807
898
                authors=[])
808
899
        self.assertFormatterResult("""\
809
 
1: Line-Log-Formatte... 2005-11-22 add a
 
900
1: Line-Log-Formatte... 2005-11-23 add a
810
901
""",
811
902
            wt.branch, log.LineLogFormatter)
812
903
 
813
904
    def test_trailing_newlines(self):
814
905
        wt = self.make_branch_and_tree('.')
815
 
        b = self.make_commits_with_trailing_newlines(wt)
 
906
        b = make_commits_with_trailing_newlines(wt)
816
907
        self.assertFormatterResult("""\
817
 
3: Joe Foo 2005-11-22 single line with trailing newline
818
 
2: Joe Foo 2005-11-22 multiline
819
 
1: Joe Foo 2005-11-22 simple log message
 
908
3: Joe Foo 2005-11-21 single line with trailing newline
 
909
2: Joe Bar 2005-11-21 multiline
 
910
1: Joe Foo 2005-11-21 simple log message
820
911
""",
821
912
            b, log.LineLogFormatter)
822
913
 
833
924
    def test_line_log_with_tags(self):
834
925
        wt = self._prepare_tree_with_merges(with_tags=True)
835
926
        self.assertFormatterResult("""\
836
 
3: Joe Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
 
927
3: Jane Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
837
928
2: Joe Foo 2005-11-22 [merge] {v0.2} rev-2
838
929
1: Joe Foo 2005-11-22 rev-1
839
930
""",
851
942
                committer='Line-Log-Formatter Tester <test@line.log>',
852
943
                authors=[])
853
944
        self.assertFormatterResult("""\
854
 
1: Line-Log-Formatte... 2005-11-22 add a
 
945
1: Line-Log-Formatte... 2005-11-23 add a
855
946
""",
856
947
            wt.branch, log.LineLogFormatter)
857
948
 
858
949
    def test_line_merge_revs_log_single_merge_revision(self):
859
 
        wt = self._prepare_tree_with_merges()
 
950
        wt = self.make_branch_and_memory_tree('.')
 
951
        wt.lock_write()
 
952
        self.addCleanup(wt.unlock)
 
953
        wt.add('')
 
954
        wt.commit('rev-1', rev_id='rev-1',
 
955
                  timestamp=1132586655, timezone=36000,
 
956
                  committer='Joe Foo <joe@foo.com>')
 
957
        wt.commit('rev-merged', rev_id='rev-2a',
 
958
                  timestamp=1132586700, timezone=36000,
 
959
                  committer='Joe Foo <joe@foo.com>')
 
960
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
961
        wt.branch.set_last_revision_info(1, 'rev-1')
 
962
        wt.commit('rev-2', rev_id='rev-2b',
 
963
                  timestamp=1132586800, timezone=36000,
 
964
                  committer='Joe Foo <joe@foo.com>')
860
965
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
861
966
        rev = revspec.in_history(wt.branch)
862
967
        self.assertFormatterResult("""\
867
972
            show_log_kwargs=dict(start_revision=rev, end_revision=rev))
868
973
 
869
974
    def test_line_merge_revs_log_with_merges(self):
870
 
        wt = self._prepare_tree_with_merges()
 
975
        wt = self.make_branch_and_memory_tree('.')
 
976
        wt.lock_write()
 
977
        self.addCleanup(wt.unlock)
 
978
        wt.add('')
 
979
        wt.commit('rev-1', rev_id='rev-1',
 
980
                  timestamp=1132586655, timezone=36000,
 
981
                  committer='Joe Foo <joe@foo.com>')
 
982
        wt.commit('rev-merged', rev_id='rev-2a',
 
983
                  timestamp=1132586700, timezone=36000,
 
984
                  committer='Joe Foo <joe@foo.com>')
 
985
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
986
        wt.branch.set_last_revision_info(1, 'rev-1')
 
987
        wt.commit('rev-2', rev_id='rev-2b',
 
988
                  timestamp=1132586800, timezone=36000,
 
989
                  committer='Joe Foo <joe@foo.com>')
871
990
        self.assertFormatterResult("""\
872
991
2: Joe Foo 2005-11-22 [merge] rev-2
873
992
  1.1.1: Joe Foo 2005-11-22 rev-merged
877
996
            formatter_kwargs=dict(levels=0))
878
997
 
879
998
 
880
 
class TestGetViewRevisions(tests.TestCaseWithTransport, TestLogMixin):
881
 
 
882
 
    def _get_view_revisions(self, *args, **kwargs):
883
 
        return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
884
 
                                    log.get_view_revisions, *args, **kwargs)
 
999
class TestGetViewRevisions(tests.TestCaseWithTransport):
885
1000
 
886
1001
    def make_tree_with_commits(self):
887
1002
        """Create a tree with well-known revision ids"""
888
1003
        wt = self.make_branch_and_tree('tree1')
889
 
        self.wt_commit(wt, 'commit one', rev_id='1')
890
 
        self.wt_commit(wt, 'commit two', rev_id='2')
891
 
        self.wt_commit(wt, 'commit three', rev_id='3')
 
1004
        wt.commit('commit one', rev_id='1')
 
1005
        wt.commit('commit two', rev_id='2')
 
1006
        wt.commit('commit three', rev_id='3')
892
1007
        mainline_revs = [None, '1', '2', '3']
893
1008
        rev_nos = {'1': 1, '2': 2, '3': 3}
894
1009
        return mainline_revs, rev_nos, wt
897
1012
        """Create a tree with well-known revision ids and a merge"""
898
1013
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
899
1014
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
900
 
        self.wt_commit(tree2, 'four-a', rev_id='4a')
 
1015
        tree2.commit('four-a', rev_id='4a')
901
1016
        wt.merge_from_branch(tree2.branch)
902
 
        self.wt_commit(wt, 'four-b', rev_id='4b')
 
1017
        wt.commit('four-b', rev_id='4b')
903
1018
        mainline_revs.append('4b')
904
1019
        rev_nos['4b'] = 4
905
1020
        # 4a: 3.1.1
953
1068
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
954
1069
        wt.lock_read()
955
1070
        self.addCleanup(wt.unlock)
956
 
        revisions = list(self._get_view_revisions(
 
1071
        revisions = list(log.get_view_revisions(
957
1072
                mainline_revs, rev_nos, wt.branch, 'forward'))
958
1073
        self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0)],
959
1074
                         revisions)
960
 
        revisions2 = list(self._get_view_revisions(
 
1075
        revisions2 = list(log.get_view_revisions(
961
1076
                mainline_revs, rev_nos, wt.branch, 'forward',
962
1077
                include_merges=False))
963
1078
        self.assertEqual(revisions, revisions2)
967
1082
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
968
1083
        wt.lock_read()
969
1084
        self.addCleanup(wt.unlock)
970
 
        revisions = list(self._get_view_revisions(
 
1085
        revisions = list(log.get_view_revisions(
971
1086
                mainline_revs, rev_nos, wt.branch, 'reverse'))
972
1087
        self.assertEqual([('3', '3', 0), ('2', '2', 0), ('1', '1', 0), ],
973
1088
                         revisions)
974
 
        revisions2 = list(self._get_view_revisions(
 
1089
        revisions2 = list(log.get_view_revisions(
975
1090
                mainline_revs, rev_nos, wt.branch, 'reverse',
976
1091
                include_merges=False))
977
1092
        self.assertEqual(revisions, revisions2)
981
1096
        mainline_revs, rev_nos, wt = self.make_tree_with_merges()
982
1097
        wt.lock_read()
983
1098
        self.addCleanup(wt.unlock)
984
 
        revisions = list(self._get_view_revisions(
 
1099
        revisions = list(log.get_view_revisions(
985
1100
                mainline_revs, rev_nos, wt.branch, 'forward'))
986
1101
        self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
987
1102
                          ('4b', '4', 0), ('4a', '3.1.1', 1)],
988
1103
                         revisions)
989
 
        revisions = list(self._get_view_revisions(
 
1104
        revisions = list(log.get_view_revisions(
990
1105
                mainline_revs, rev_nos, wt.branch, 'forward',
991
1106
                include_merges=False))
992
1107
        self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
998
1113
        mainline_revs, rev_nos, wt = self.make_tree_with_merges()
999
1114
        wt.lock_read()
1000
1115
        self.addCleanup(wt.unlock)
1001
 
        revisions = list(self._get_view_revisions(
 
1116
        revisions = list(log.get_view_revisions(
1002
1117
                mainline_revs, rev_nos, wt.branch, 'reverse'))
1003
1118
        self.assertEqual([('4b', '4', 0), ('4a', '3.1.1', 1),
1004
1119
                          ('3', '3', 0), ('2', '2', 0), ('1', '1', 0)],
1005
1120
                         revisions)
1006
 
        revisions = list(self._get_view_revisions(
 
1121
        revisions = list(log.get_view_revisions(
1007
1122
                mainline_revs, rev_nos, wt.branch, 'reverse',
1008
1123
                include_merges=False))
1009
1124
        self.assertEqual([('4b', '4', 0), ('3', '3', 0), ('2', '2', 0),
1015
1130
        mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1016
1131
        b.lock_read()
1017
1132
        self.addCleanup(b.unlock)
1018
 
        revisions = list(self._get_view_revisions(
 
1133
        revisions = list(log.get_view_revisions(
1019
1134
                mainline_revs, rev_nos, b, 'forward'))
1020
1135
        expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1021
1136
                    ('3b', '2.2.1', 1), ('3a', '2.1.1', 2), ('4b', '4', 0),
1022
1137
                    ('4a', '2.2.2', 1)]
1023
1138
        self.assertEqual(expected, revisions)
1024
 
        revisions = list(self._get_view_revisions(
 
1139
        revisions = list(log.get_view_revisions(
1025
1140
                mainline_revs, rev_nos, b, 'forward',
1026
1141
                include_merges=False))
1027
1142
        self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1028
1143
                          ('4b', '4', 0)],
1029
1144
                         revisions)
1030
1145
 
 
1146
 
1031
1147
    def test_file_id_for_range(self):
1032
1148
        mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1033
1149
        b.lock_read()
1038
1154
            return revspec.in_history(branch)
1039
1155
 
1040
1156
        def view_revs(start_rev, end_rev, file_id, direction):
1041
 
            revs = self.applyDeprecated(
1042
 
                symbol_versioning.deprecated_in((2, 2, 0)),
1043
 
                log.calculate_view_revisions,
 
1157
            revs = log.calculate_view_revisions(
1044
1158
                b,
1045
1159
                start_rev, # start_revision
1046
1160
                end_rev, # end_revision
1052
1166
 
1053
1167
        rev_3a = rev_from_rev_id('3a', b)
1054
1168
        rev_4b = rev_from_rev_id('4b', b)
1055
 
        self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1),
1056
 
                          ('3a', '2.1.1', 2)],
 
1169
        self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
1057
1170
                          view_revs(rev_3a, rev_4b, 'f-id', 'reverse'))
1058
1171
        # Note: 3c still appears before 3a here because of depth-based sorting
1059
 
        self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1),
1060
 
                          ('3a', '2.1.1', 2)],
 
1172
        self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
1061
1173
                          view_revs(rev_3a, rev_4b, 'f-id', 'forward'))
1062
1174
 
1063
1175
 
1064
1176
class TestGetRevisionsTouchingFileID(tests.TestCaseWithTransport):
1065
1177
 
1066
 
    def get_view_revisions(self, *args):
1067
 
        return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
1068
 
                                    log.get_view_revisions, *args)
1069
 
 
1070
1178
    def create_tree_with_single_merge(self):
1071
1179
        """Create a branch with a moderate layout.
1072
1180
 
1090
1198
        #       use it. Since 'log' only uses the tree in a readonly
1091
1199
        #       fashion, it seems a shame to regenerate an identical
1092
1200
        #       tree for each test.
1093
 
        # TODO: vila 20100122 One way to address the shame above will be to
1094
 
        #       create a memory tree during test parametrization and give a
1095
 
        #       *copy* of this tree to each test. Copying a memory tree ought
1096
 
        #       to be cheap, at least cheaper than creating them with such
1097
 
        #       complex setups.
1098
1201
        tree = self.make_branch_and_tree('tree')
1099
1202
        tree.lock_write()
1100
1203
        self.addCleanup(tree.unlock)
1175
1278
        mainline = tree.branch.revision_history()
1176
1279
        mainline.insert(0, None)
1177
1280
        revnos = dict((rev, idx+1) for idx, rev in enumerate(mainline))
1178
 
        view_revs_iter = self.get_view_revisions(
1179
 
            mainline, revnos, tree.branch, 'reverse', True)
 
1281
        view_revs_iter = log.get_view_revisions(mainline, revnos, tree.branch,
 
1282
                                                'reverse', True)
1180
1283
        actual_revs = log._filter_revisions_touching_file_id(
1181
 
            tree.branch, file_id, list(view_revs_iter))
 
1284
                            tree.branch,
 
1285
                            file_id,
 
1286
                            list(view_revs_iter))
1182
1287
        self.assertEqual(revisions, [r for r, revno, depth in actual_revs])
1183
1288
 
1184
1289
    def test_file_id_f1(self):
1236
1341
 
1237
1342
class TestLogFormatter(tests.TestCase):
1238
1343
 
1239
 
    def setUp(self):
1240
 
        super(TestLogFormatter, self).setUp()
1241
 
        self.rev = revision.Revision('a-id')
1242
 
        self.lf = log.LogFormatter(None)
1243
 
 
1244
1344
    def test_short_committer(self):
1245
 
        def assertCommitter(expected, committer):
1246
 
            self.rev.committer = committer
1247
 
            self.assertEqual(expected, self.lf.short_committer(self.rev))
1248
 
 
1249
 
        assertCommitter('John Doe', 'John Doe <jdoe@example.com>')
1250
 
        assertCommitter('John Smith', 'John Smith <jsmith@example.com>')
1251
 
        assertCommitter('John Smith', 'John Smith')
1252
 
        assertCommitter('jsmith@example.com', 'jsmith@example.com')
1253
 
        assertCommitter('jsmith@example.com', '<jsmith@example.com>')
1254
 
        assertCommitter('John Smith', 'John Smith jsmith@example.com')
 
1345
        rev = revision.Revision('a-id')
 
1346
        rev.committer = 'John Doe <jdoe@example.com>'
 
1347
        lf = log.LogFormatter(None)
 
1348
        self.assertEqual('John Doe', lf.short_committer(rev))
 
1349
        rev.committer = 'John Smith <jsmith@example.com>'
 
1350
        self.assertEqual('John Smith', lf.short_committer(rev))
 
1351
        rev.committer = 'John Smith'
 
1352
        self.assertEqual('John Smith', lf.short_committer(rev))
 
1353
        rev.committer = 'jsmith@example.com'
 
1354
        self.assertEqual('jsmith@example.com', lf.short_committer(rev))
 
1355
        rev.committer = '<jsmith@example.com>'
 
1356
        self.assertEqual('jsmith@example.com', lf.short_committer(rev))
 
1357
        rev.committer = 'John Smith jsmith@example.com'
 
1358
        self.assertEqual('John Smith', lf.short_committer(rev))
1255
1359
 
1256
1360
    def test_short_author(self):
1257
 
        def assertAuthor(expected, author):
1258
 
            self.rev.properties['author'] = author
1259
 
            self.assertEqual(expected, self.lf.short_author(self.rev))
1260
 
 
1261
 
        assertAuthor('John Smith', 'John Smith <jsmith@example.com>')
1262
 
        assertAuthor('John Smith', 'John Smith')
1263
 
        assertAuthor('jsmith@example.com', 'jsmith@example.com')
1264
 
        assertAuthor('jsmith@example.com', '<jsmith@example.com>')
1265
 
        assertAuthor('John Smith', 'John Smith jsmith@example.com')
1266
 
 
1267
 
    def test_short_author_from_committer(self):
1268
 
        self.rev.committer = 'John Doe <jdoe@example.com>'
1269
 
        self.assertEqual('John Doe', self.lf.short_author(self.rev))
1270
 
 
1271
 
    def test_short_author_from_authors(self):
1272
 
        self.rev.properties['authors'] = ('John Smith <jsmith@example.com>\n'
1273
 
                                          'Jane Rey <jrey@example.com>')
1274
 
        self.assertEqual('John Smith', self.lf.short_author(self.rev))
 
1361
        rev = revision.Revision('a-id')
 
1362
        rev.committer = 'John Doe <jdoe@example.com>'
 
1363
        lf = log.LogFormatter(None)
 
1364
        self.assertEqual('John Doe', lf.short_author(rev))
 
1365
        rev.properties['author'] = 'John Smith <jsmith@example.com>'
 
1366
        self.assertEqual('John Smith', lf.short_author(rev))
 
1367
        rev.properties['author'] = 'John Smith'
 
1368
        self.assertEqual('John Smith', lf.short_author(rev))
 
1369
        rev.properties['author'] = 'jsmith@example.com'
 
1370
        self.assertEqual('jsmith@example.com', lf.short_author(rev))
 
1371
        rev.properties['author'] = '<jsmith@example.com>'
 
1372
        self.assertEqual('jsmith@example.com', lf.short_author(rev))
 
1373
        rev.properties['author'] = 'John Smith jsmith@example.com'
 
1374
        self.assertEqual('John Smith', lf.short_author(rev))
 
1375
        del rev.properties['author']
 
1376
        rev.properties['authors'] = ('John Smith <jsmith@example.com>\n'
 
1377
                'Jane Rey <jrey@example.com>')
 
1378
        self.assertEqual('John Smith', lf.short_author(rev))
1275
1379
 
1276
1380
 
1277
1381
class TestReverseByDepth(tests.TestCase):
1426
1530
 
1427
1531
 
1428
1532
 
1429
 
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
 
1533
class TestLogWithBugs(TestCaseForLogFormatter):
1430
1534
 
1431
1535
    def setUp(self):
1432
1536
        TestCaseForLogFormatter.setUp(self)
1439
1543
        tree = self.make_branch_and_tree(u'.')
1440
1544
        self.build_tree(['a', 'b'])
1441
1545
        tree.add('a')
1442
 
        self.wt_commit(tree, 'simple log message', rev_id='a1',
1443
 
                       revprops={'bugs': 'test://bug/id fixed'})
 
1546
        tree.commit('simple log message', rev_id='a1',
 
1547
                    timestamp=1132586655.459960938, timezone=-6*3600,
 
1548
                    committer='Joe Foo <joe@foo.com>',
 
1549
                    revprops={'bugs': 'test://bug/id fixed'})
1444
1550
        tree.add('b')
1445
 
        self.wt_commit(tree, 'multiline\nlog\nmessage\n', rev_id='a2',
1446
 
                       authors=['Joe Bar <joe@bar.com>'],
1447
 
                       revprops={'bugs': 'test://bug/id fixed\n'
1448
 
                                 'test://bug/2 fixed'})
 
1551
        tree.commit('multiline\nlog\nmessage\n', rev_id='a2',
 
1552
                    timestamp=1132586842.411175966, timezone=-6*3600,
 
1553
                    committer='Joe Foo <joe@foo.com>',
 
1554
                    authors=['Joe Bar <joe@bar.com>'],
 
1555
                    revprops={'bugs': 'test://bug/id fixed\n'
 
1556
                                      'test://bug/2 fixed'})
1449
1557
        return tree
1450
1558
 
1451
1559
 
1458
1566
author: Joe Bar <joe@bar.com>
1459
1567
committer: Joe Foo <joe@foo.com>
1460
1568
branch nick: work
1461
 
timestamp: Tue 2005-11-22 00:00:01 +0000
 
1569
timestamp: Mon 2005-11-21 09:27:22 -0600
1462
1570
message:
1463
1571
  multiline
1464
1572
  log
1468
1576
fixes bug(s): test://bug/id
1469
1577
committer: Joe Foo <joe@foo.com>
1470
1578
branch nick: work
1471
 
timestamp: Tue 2005-11-22 00:00:00 +0000
 
1579
timestamp: Mon 2005-11-21 09:24:15 -0600
1472
1580
message:
1473
1581
  simple log message
1474
1582
""",
1477
1585
    def test_short_bugs(self):
1478
1586
        tree = self.make_commits_with_bugs()
1479
1587
        self.assertFormatterResult("""\
1480
 
    2 Joe Bar\t2005-11-22
 
1588
    2 Joe Bar\t2005-11-21
1481
1589
      fixes bug(s): test://bug/id test://bug/2
1482
1590
      multiline
1483
1591
      log
1484
1592
      message
1485
1593
 
1486
 
    1 Joe Foo\t2005-11-22
 
1594
    1 Joe Foo\t2005-11-21
1487
1595
      fixes bug(s): test://bug/id
1488
1596
      simple log message
1489
1597
 
1493
1601
    def test_wrong_bugs_property(self):
1494
1602
        tree = self.make_branch_and_tree(u'.')
1495
1603
        self.build_tree(['foo'])
1496
 
        self.wt_commit(tree, 'simple log message', rev_id='a1',
1497
 
                       revprops={'bugs': 'test://bug/id invalid_value'})
 
1604
        tree.commit('simple log message', rev_id='a1',
 
1605
              timestamp=1132586655.459960938, timezone=-6*3600,
 
1606
              committer='Joe Foo <joe@foo.com>',
 
1607
              revprops={'bugs': 'test://bug/id invalid_value'})
1498
1608
        self.assertFormatterResult("""\
1499
 
    1 Joe Foo\t2005-11-22
 
1609
    1 Joe Foo\t2005-11-21
1500
1610
      simple log message
1501
1611
 
1502
1612
""",