33
33
super(TestCaseWithoutPropsHandler, self).setUp()
34
34
# keep a reference to the "current" custom prop. handler registry
35
35
self.properties_handler_registry = log.properties_handler_registry
36
# clean up the registry in log
36
# Use a clean registry for log
37
37
log.properties_handler_registry = registry.Registry()
40
super(TestCaseWithoutPropsHandler, self)._cleanup()
41
# restore the custom properties handler registry
42
log.properties_handler_registry = self.properties_handler_registry
40
log.properties_handler_registry = self.properties_handler_registry
41
self.addCleanup(restore)
45
44
class LogCatcher(log.LogFormatter):
46
"""Pull log messages into list rather than displaying them.
48
For ease of testing we save log messages here rather than actually
49
formatting them, so that we can precisely check the result without
50
being too dependent on the exact formatting.
52
We should also test the LogFormatter.
45
"""Pull log messages into a list rather than displaying them.
47
To simplify testing we save logged revisions here rather than actually
48
formatting anything, so that we can precisely check the result without
49
being dependent on the formatting.
55
52
supports_delta = True
57
54
def __init__(self):
58
55
super(LogCatcher, self).__init__(to_file=None)
61
58
def log_revision(self, revision):
62
self.logs.append(revision)
59
self.revisions.append(revision)
65
62
class TestShowLog(tests.TestCaseWithTransport):
106
103
lf = LogCatcher()
107
104
log.show_log(wt.branch, lf)
109
self.assertEqual([], lf.logs)
106
self.assertEqual([], lf.revisions)
111
108
def test_empty_commit(self):
112
109
wt = self.make_branch_and_tree('.')
114
111
wt.commit('empty commit')
115
112
lf = LogCatcher()
116
113
log.show_log(wt.branch, lf, verbose=True)
117
self.assertEqual(1, len(lf.logs))
118
self.assertEqual('1', lf.logs[0].revno)
119
self.assertEqual('empty commit', lf.logs[0].rev.message)
120
self.checkDelta(lf.logs[0].delta)
115
self.assertEqual(1, len(revs))
116
self.assertEqual('1', revs[0].revno)
117
self.assertEqual('empty commit', revs[0].rev.message)
118
self.checkDelta(revs[0].delta)
122
120
def test_simple_commit(self):
123
121
wt = self.make_branch_and_tree('.')
129
127
u'<test@example.com>')
130
128
lf = LogCatcher()
131
129
log.show_log(wt.branch, lf, verbose=True)
132
self.assertEqual(2, len(lf.logs))
130
self.assertEqual(2, len(lf.revisions))
133
131
# first one is most recent
134
log_entry = lf.logs[0]
132
log_entry = lf.revisions[0]
135
133
self.assertEqual('2', log_entry.revno)
136
134
self.assertEqual('add one file', log_entry.rev.message)
137
135
self.checkDelta(log_entry.delta, added=['hello'])
144
142
lf = LogCatcher()
145
143
log.show_log(wt.branch, lf, verbose=True)
146
committed_msg = lf.logs[0].rev.message
144
committed_msg = lf.revisions[0].rev.message
147
145
self.assertNotEqual(msg, committed_msg)
148
146
self.assertTrue(len(committed_msg) > len(msg))
158
156
lf = LogCatcher()
159
157
log.show_log(wt.branch, lf, verbose=True)
160
committed_msg = lf.logs[0].rev.message
158
committed_msg = lf.revisions[0].rev.message
161
159
self.assertEqual(msg, committed_msg)
163
161
def test_deltas_in_merge_revisions(self):
181
179
lf.supports_merge_revisions = True
182
180
log.show_log(b, lf, verbose=True)
184
self.assertEqual(3, len(lf.logs))
183
self.assertEqual(3, len(revs))
186
logentry = lf.logs[0]
187
186
self.assertEqual('2', logentry.revno)
188
187
self.assertEqual('merge child branch', logentry.rev.message)
189
188
self.checkDelta(logentry.delta, removed=['file1'], modified=['file2'])
191
logentry = lf.logs[1]
192
191
self.assertEqual('1.1.1', logentry.revno)
193
192
self.assertEqual('remove file1 and modify file2', logentry.rev.message)
194
193
self.checkDelta(logentry.delta, removed=['file1'], modified=['file2'])
196
logentry = lf.logs[2]
197
196
self.assertEqual('1', logentry.revno)
198
197
self.assertEqual('add file1 and file2', logentry.rev.message)
199
198
self.checkDelta(logentry.delta, added=['file1', 'file2'])