6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005-2013, 2016 Canonical Ltd
|
1685.1.80
by Wouter van Heyst
more code cleanup |
2 |
#
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1685.1.80
by Wouter van Heyst
more code cleanup |
7 |
#
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1685.1.80
by Wouter van Heyst
more code cleanup |
12 |
#
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
16 |
|
17 |
import os |
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
18 |
from cStringIO import StringIO |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
19 |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
20 |
from bzrlib import ( |
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
21 |
branchbuilder, |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
22 |
errors, |
23 |
log, |
|
24 |
registry, |
|
25 |
revision, |
|
26 |
revisionspec, |
|
27 |
tests, |
|
6583.4.5
by Reagan Sanders
Added a test case covering the possibility of UTF-8 characters within the name portion of a GPG key. This can happen during a 'bzr log --signatures' command. |
28 |
gpg, |
29 |
trace, |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
30 |
)
|
31 |
||
32 |
||
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
33 |
class TestLogMixin(object): |
34 |
||
35 |
def wt_commit(self, wt, message, **kwargs): |
|
36 |
"""Use some mostly fixed values for commits to simplify tests.
|
|
37 |
||
38 |
Tests can use this function to get some commit attributes. The time
|
|
39 |
stamp is incremented at each commit.
|
|
40 |
"""
|
|
41 |
if getattr(self, 'timestamp', None) is None: |
|
42 |
self.timestamp = 1132617600 # Mon 2005-11-22 00:00:00 +0000 |
|
43 |
else: |
|
44 |
self.timestamp += 1 # 1 second between each commit |
|
45 |
kwargs.setdefault('timestamp', self.timestamp) |
|
46 |
kwargs.setdefault('timezone', 0) # UTC |
|
47 |
kwargs.setdefault('committer', 'Joe Foo <joe@foo.com>') |
|
48 |
||
49 |
return wt.commit(message, **kwargs) |
|
50 |
||
51 |
||
52 |
class TestCaseForLogFormatter(tests.TestCaseWithTransport, TestLogMixin): |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
53 |
|
54 |
def setUp(self): |
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
55 |
super(TestCaseForLogFormatter, self).setUp() |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
56 |
# keep a reference to the "current" custom prop. handler registry
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
57 |
self.properties_handler_registry = log.properties_handler_registry |
4325.4.3
by Vincent Ladeuil
More cleanups. |
58 |
# Use a clean registry for log
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
59 |
log.properties_handler_registry = registry.Registry() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
60 |
|
4325.4.3
by Vincent Ladeuil
More cleanups. |
61 |
def restore(): |
62 |
log.properties_handler_registry = self.properties_handler_registry |
|
63 |
self.addCleanup(restore) |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
64 |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
65 |
def assertFormatterResult(self, result, branch, formatter_class, |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
66 |
formatter_kwargs=None, show_log_kwargs=None): |
4857.4.5
by John Arbash Meinel
We don't need the utf8 option, no test actually wanted to run without it, |
67 |
logfile = self.make_utf8_encoded_stringio() |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
68 |
if formatter_kwargs is None: |
69 |
formatter_kwargs = {} |
|
70 |
formatter = formatter_class(to_file=logfile, **formatter_kwargs) |
|
71 |
if show_log_kwargs is None: |
|
72 |
show_log_kwargs = {} |
|
73 |
log.show_log(branch, formatter, **show_log_kwargs) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
74 |
self.assertEqualDiff(result, logfile.getvalue()) |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
75 |
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
76 |
def make_standard_commit(self, branch_nick, **kwargs): |
77 |
wt = self.make_branch_and_tree('.') |
|
78 |
wt.lock_write() |
|
79 |
self.addCleanup(wt.unlock) |
|
80 |
self.build_tree(['a']) |
|
81 |
wt.add(['a']) |
|
82 |
wt.branch.nick = branch_nick |
|
83 |
kwargs.setdefault('committer', 'Lorem Ipsum <test@example.com>') |
|
84 |
kwargs.setdefault('authors', ['John Doe <jdoe@example.com>']) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
85 |
self.wt_commit(wt, 'add a', **kwargs) |
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
86 |
return wt |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
87 |
|
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
88 |
def make_commits_with_trailing_newlines(self, wt): |
89 |
"""Helper method for LogFormatter tests"""
|
|
90 |
b = wt.branch |
|
91 |
b.nick = 'test' |
|
4955.4.16
by Vincent Ladeuil
Be windows-friendly and don't left opened files behind. |
92 |
self.build_tree_contents([('a', 'hello moto\n')]) |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
93 |
self.wt_commit(wt, 'simple log message', rev_id='a1') |
4955.4.16
by Vincent Ladeuil
Be windows-friendly and don't left opened files behind. |
94 |
self.build_tree_contents([('b', 'goodbye\n')]) |
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
95 |
wt.add('b') |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
96 |
self.wt_commit(wt, 'multiline\nlog\nmessage\n', rev_id='a2') |
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
97 |
|
4955.4.16
by Vincent Ladeuil
Be windows-friendly and don't left opened files behind. |
98 |
self.build_tree_contents([('c', 'just another manic monday\n')]) |
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
99 |
wt.add('c') |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
100 |
self.wt_commit(wt, 'single line with trailing newline\n', rev_id='a3') |
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
101 |
return b |
102 |
||
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
103 |
def _prepare_tree_with_merges(self, with_tags=False): |
104 |
wt = self.make_branch_and_memory_tree('.') |
|
105 |
wt.lock_write() |
|
106 |
self.addCleanup(wt.unlock) |
|
107 |
wt.add('') |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
108 |
self.wt_commit(wt, 'rev-1', rev_id='rev-1') |
109 |
self.wt_commit(wt, 'rev-merged', rev_id='rev-2a') |
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
110 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
111 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
112 |
self.wt_commit(wt, 'rev-2', rev_id='rev-2b') |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
113 |
if with_tags: |
114 |
branch = wt.branch |
|
115 |
branch.tags.set_tag('v0.2', 'rev-2b') |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
116 |
self.wt_commit(wt, 'rev-3', rev_id='rev-3') |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
117 |
branch.tags.set_tag('v1.0rc1', 'rev-3') |
118 |
branch.tags.set_tag('v1.0', 'rev-3') |
|
119 |
return wt |
|
120 |
||
5691.1.2
by Jelmer Vernooij
Add tests for ghosts in mainline during log. |
121 |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
122 |
class LogCatcher(log.LogFormatter): |
4325.4.3
by Vincent Ladeuil
More cleanups. |
123 |
"""Pull log messages into a list rather than displaying them.
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
124 |
|
4325.4.3
by Vincent Ladeuil
More cleanups. |
125 |
To simplify testing we save logged revisions here rather than actually
|
4325.4.1
by Vincent Ladeuil
Some cleanups. |
126 |
formatting anything, so that we can precisely check the result without
|
4325.4.3
by Vincent Ladeuil
More cleanups. |
127 |
being dependent on the formatting.
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
128 |
"""
|
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
129 |
|
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
130 |
supports_merge_revisions = True |
2490.1.2
by John Arbash Meinel
Cleanup according to PEP8 and some other small whitespace fixes |
131 |
supports_delta = True |
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
132 |
supports_diff = True |
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
133 |
preferred_levels = 0 |
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
134 |
|
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
135 |
def __init__(self, *args, **kwargs): |
136 |
kwargs.update(dict(to_file=None)) |
|
137 |
super(LogCatcher, self).__init__(*args, **kwargs) |
|
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
138 |
self.revisions = [] |
1704.2.20
by Martin Pool
log --line shows revision numbers (Alexander) |
139 |
|
2466.8.1
by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters. |
140 |
def log_revision(self, revision): |
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
141 |
self.revisions.append(revision) |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
142 |
|
143 |
||
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
144 |
class TestShowLog(tests.TestCaseWithTransport): |
1102
by Martin Pool
- merge test refactoring from robertc |
145 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
146 |
def checkDelta(self, delta, **kw): |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
147 |
"""Check the filenames touched by a delta are as expected.
|
148 |
||
149 |
Caller only have to pass in the list of files for each part, all
|
|
150 |
unspecified parts are considered empty (and checked as such).
|
|
151 |
"""
|
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
152 |
for n in 'added', 'removed', 'renamed', 'modified', 'unchanged': |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
153 |
# By default we expect an empty list
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
154 |
expected = kw.get(n, []) |
155 |
# strip out only the path components
|
|
156 |
got = [x[0] for x in getattr(delta, n)] |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
157 |
self.assertEqual(expected, got) |
158 |
||
159 |
def assertInvalidRevisonNumber(self, br, start, end): |
|
160 |
lf = LogCatcher() |
|
161 |
self.assertRaises(errors.InvalidRevisionNumber, |
|
162 |
log.show_log, br, lf, |
|
163 |
start_revision=start, end_revision=end) |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
164 |
|
974.1.54
by aaron.bentley at utoronto
Fixed the revno bug in log |
165 |
def test_cur_revno(self): |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
166 |
wt = self.make_branch_and_tree('.') |
167 |
b = wt.branch |
|
1092.3.4
by Robert Collins
update symlink branch to integration |
168 |
|
169 |
lf = LogCatcher() |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
170 |
wt.commit('empty commit') |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
171 |
log.show_log(b, lf, verbose=True, start_revision=1, end_revision=1) |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
172 |
|
173 |
# Since there is a single revision in the branch all the combinations
|
|
174 |
# below should fail.
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
175 |
self.assertInvalidRevisonNumber(b, 2, 1) |
176 |
self.assertInvalidRevisonNumber(b, 1, 2) |
|
177 |
self.assertInvalidRevisonNumber(b, 0, 2) |
|
178 |
self.assertInvalidRevisonNumber(b, 1, 0) |
|
179 |
self.assertInvalidRevisonNumber(b, -1, 1) |
|
180 |
self.assertInvalidRevisonNumber(b, 1, -1) |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
181 |
|
182 |
def test_empty_branch(self): |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
183 |
wt = self.make_branch_and_tree('.') |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
184 |
|
185 |
lf = LogCatcher() |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
186 |
log.show_log(wt.branch, lf) |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
187 |
# no entries yet
|
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
188 |
self.assertEqual([], lf.revisions) |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
189 |
|
190 |
def test_empty_commit(self): |
|
191 |
wt = self.make_branch_and_tree('.') |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
192 |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
193 |
wt.commit('empty commit') |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
194 |
lf = LogCatcher() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
195 |
log.show_log(wt.branch, lf, verbose=True) |
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
196 |
revs = lf.revisions |
197 |
self.assertEqual(1, len(revs)) |
|
198 |
self.assertEqual('1', revs[0].revno) |
|
199 |
self.assertEqual('empty commit', revs[0].rev.message) |
|
200 |
self.checkDelta(revs[0].delta) |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
201 |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
202 |
def test_simple_commit(self): |
203 |
wt = self.make_branch_and_tree('.') |
|
204 |
wt.commit('empty commit') |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
205 |
self.build_tree(['hello']) |
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
206 |
wt.add('hello') |
2717.1.1
by Lukáš Lalinsky
Use UTF-8 encoded StringIO for log tests to avoid failures on non-ASCII committer names. |
207 |
wt.commit('add one file', |
208 |
committer=u'\u013d\xf3r\xe9m \xcdp\u0161\xfam ' |
|
209 |
u'<test@example.com>') |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
210 |
lf = LogCatcher() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
211 |
log.show_log(wt.branch, lf, verbose=True) |
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
212 |
self.assertEqual(2, len(lf.revisions)) |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
213 |
# first one is most recent
|
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
214 |
log_entry = lf.revisions[0] |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
215 |
self.assertEqual('2', log_entry.revno) |
216 |
self.assertEqual('add one file', log_entry.rev.message) |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
217 |
self.checkDelta(log_entry.delta, added=['hello']) |
3831.1.6
by John Arbash Meinel
For the simple-log tests, avoid using '\r' in the test. |
218 |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
219 |
def test_commit_message_with_control_chars(self): |
220 |
wt = self.make_branch_and_tree('.') |
|
3831.1.6
by John Arbash Meinel
For the simple-log tests, avoid using '\r' in the test. |
221 |
msg = u"All 8-bit chars: " + ''.join([unichr(x) for x in range(256)]) |
222 |
msg = msg.replace(u'\r', u'\n') |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
223 |
wt.commit(msg) |
1185.11.5
by John Arbash Meinel
Merged up-to-date against mainline, still broken. |
224 |
lf = LogCatcher() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
225 |
log.show_log(wt.branch, lf, verbose=True) |
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
226 |
committed_msg = lf.revisions[0].rev.message |
4627.1.1
by Robert Collins
Review feedback per IanC. |
227 |
if wt.branch.repository._serializer.squashes_xml_invalid_characters: |
228 |
self.assertNotEqual(msg, committed_msg) |
|
229 |
self.assertTrue(len(committed_msg) > len(msg)) |
|
230 |
else: |
|
231 |
self.assertEqual(msg, committed_msg) |
|
1393.4.2
by Harald Meland
Cleanup + better test of commit-msg control character escape code. |
232 |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
233 |
def test_commit_message_without_control_chars(self): |
234 |
wt = self.make_branch_and_tree('.') |
|
1393.4.2
by Harald Meland
Cleanup + better test of commit-msg control character escape code. |
235 |
# escaped. As ElementTree apparently does some kind of
|
236 |
# newline conversion, neither LF (\x0A) nor CR (\x0D) are
|
|
237 |
# included in the test commit message, even though they are
|
|
238 |
# valid XML 1.0 characters.
|
|
239 |
msg = "\x09" + ''.join([unichr(x) for x in range(0x20, 256)]) |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
240 |
wt.commit(msg) |
1393.4.2
by Harald Meland
Cleanup + better test of commit-msg control character escape code. |
241 |
lf = LogCatcher() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
242 |
log.show_log(wt.branch, lf, verbose=True) |
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
243 |
committed_msg = lf.revisions[0].rev.message |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
244 |
self.assertEqual(msg, committed_msg) |
1185.31.22
by John Arbash Meinel
[merge] bzr.dev |
245 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
246 |
def test_deltas_in_merge_revisions(self): |
247 |
"""Check deltas created for both mainline and merge revisions"""
|
|
248 |
wt = self.make_branch_and_tree('parent') |
|
249 |
self.build_tree(['parent/file1', 'parent/file2', 'parent/file3']) |
|
250 |
wt.add('file1') |
|
251 |
wt.add('file2') |
|
252 |
wt.commit(message='add file1 and file2') |
|
2581.1.6
by Martin Pool
fix up more run_bzr callers |
253 |
self.run_bzr('branch parent child') |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
254 |
os.unlink('child/file1') |
6437.20.3
by Wouter van Heyst
mechanically replace file().write() pattern with a with-keyword version |
255 |
with file('child/file2', 'wb') as f: f.write('hello\n') |
2581.1.6
by Martin Pool
fix up more run_bzr callers |
256 |
self.run_bzr(['commit', '-m', 'remove file1 and modify file2', |
257 |
'child']) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
258 |
os.chdir('parent') |
2581.1.6
by Martin Pool
fix up more run_bzr callers |
259 |
self.run_bzr('merge ../child') |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
260 |
wt.commit('merge child branch') |
261 |
os.chdir('..') |
|
262 |
b = wt.branch |
|
263 |
lf = LogCatcher() |
|
264 |
lf.supports_merge_revisions = True |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
265 |
log.show_log(b, lf, verbose=True) |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
266 |
|
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
267 |
revs = lf.revisions |
268 |
self.assertEqual(3, len(revs)) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
269 |
|
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
270 |
logentry = revs[0] |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
271 |
self.assertEqual('2', logentry.revno) |
272 |
self.assertEqual('merge child branch', logentry.rev.message) |
|
273 |
self.checkDelta(logentry.delta, removed=['file1'], modified=['file2']) |
|
274 |
||
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
275 |
logentry = revs[1] |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
276 |
self.assertEqual('1.1.1', logentry.revno) |
277 |
self.assertEqual('remove file1 and modify file2', logentry.rev.message) |
|
278 |
self.checkDelta(logentry.delta, removed=['file1'], modified=['file2']) |
|
279 |
||
4325.4.4
by Vincent Ladeuil
Clarify LogCatcher purpose. |
280 |
logentry = revs[2] |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
281 |
self.assertEqual('1', logentry.revno) |
282 |
self.assertEqual('add file1 and file2', logentry.rev.message) |
|
283 |
self.checkDelta(logentry.delta, added=['file1', 'file2']) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
284 |
|
285 |
||
6583.4.5
by Reagan Sanders
Added a test case covering the possibility of UTF-8 characters within the name portion of a GPG key. This can happen during a 'bzr log --signatures' command. |
286 |
class TestFormatSignatureValidity(tests.TestCaseWithTransport): |
287 |
class UTFLoopbackGPGStrategy(gpg.LoopbackGPGStrategy): |
|
288 |
def verify(self, content, testament): |
|
289 |
return (gpg.SIGNATURE_VALID, |
|
290 |
u'UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>') |
|
291 |
||
292 |
def has_signature_for_revision_id(self, revision_id): |
|
293 |
return True |
|
294 |
||
295 |
def get_signature_text(self, revision_id): |
|
296 |
return '' |
|
297 |
||
298 |
def test_format_signature_validity_utf(self): |
|
299 |
"""Check that GPG signatures containing UTF-8 names are formatted
|
|
300 |
correctly."""
|
|
301 |
# Monkey patch to use our UTF-8 generating GPGStrategy
|
|
302 |
self.overrideAttr(gpg, 'GPGStrategy', self.UTFLoopbackGPGStrategy) |
|
303 |
wt = self.make_branch_and_tree('.') |
|
304 |
revid = wt.commit('empty commit') |
|
305 |
repo = wt.branch.repository |
|
306 |
# Monkey patch out checking if this rev is actually signed, since we
|
|
307 |
# can't sign it without a heavier TestCase and LoopbackGPGStrategy
|
|
308 |
# doesn't care anyways.
|
|
309 |
self.overrideAttr(repo, 'has_signature_for_revision_id', |
|
310 |
self.has_signature_for_revision_id) |
|
311 |
self.overrideAttr(repo, 'get_signature_text', self.get_signature_text) |
|
312 |
out = log.format_signature_validity(revid, repo) |
|
313 |
self.assertEqual( |
|
314 |
u'valid signature from UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>', |
|
315 |
out) |
|
316 |
||
317 |
||
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
318 |
class TestShortLogFormatter(TestCaseForLogFormatter): |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
319 |
|
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
320 |
def test_trailing_newlines(self): |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
321 |
wt = self.make_branch_and_tree('.') |
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
322 |
b = self.make_commits_with_trailing_newlines(wt) |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
323 |
self.assertFormatterResult("""\ |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
324 |
3 Joe Foo\t2005-11-22 |
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
325 |
single line with trailing newline
|
326 |
||
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
327 |
2 Joe Foo\t2005-11-22 |
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
328 |
multiline
|
329 |
log
|
|
330 |
message
|
|
331 |
||
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
332 |
1 Joe Foo\t2005-11-22 |
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
333 |
simple log message
|
334 |
||
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
335 |
""", |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
336 |
b, log.ShortLogFormatter) |
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
337 |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
338 |
def test_short_log_with_merges(self): |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
339 |
wt = self._prepare_tree_with_merges() |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
340 |
self.assertFormatterResult("""\ |
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
341 |
2 Joe Foo\t2005-11-22 [merge] |
342 |
rev-2
|
|
343 |
||
344 |
1 Joe Foo\t2005-11-22 |
|
345 |
rev-1
|
|
346 |
||
4221.2.3
by Ian Clatworthy
jam feedback: don't show advice if --levels explicitly given |
347 |
""", |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
348 |
wt.branch, log.ShortLogFormatter) |
4221.2.3
by Ian Clatworthy
jam feedback: don't show advice if --levels explicitly given |
349 |
|
350 |
def test_short_log_with_merges_and_advice(self): |
|
351 |
wt = self._prepare_tree_with_merges() |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
352 |
self.assertFormatterResult("""\ |
4221.2.3
by Ian Clatworthy
jam feedback: don't show advice if --levels explicitly given |
353 |
2 Joe Foo\t2005-11-22 [merge] |
354 |
rev-2
|
|
355 |
||
356 |
1 Joe Foo\t2005-11-22 |
|
357 |
rev-1
|
|
358 |
||
6123.11.13
by Martin von Gagern
Rename --include-sidelines to --include-merged. |
359 |
Use --include-merged or -n0 to see merged revisions.
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
360 |
""", |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
361 |
wt.branch, log.ShortLogFormatter, |
362 |
formatter_kwargs=dict(show_advice=True)) |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
363 |
|
3943.4.2
by John Arbash Meinel
Add a test case which exercises this code path. |
364 |
def test_short_log_with_merges_and_range(self): |
4955.4.19
by Vincent Ladeuil
Less code duplication. |
365 |
wt = self._prepare_tree_with_merges() |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
366 |
self.wt_commit(wt, 'rev-3a', rev_id='rev-3a') |
3943.4.2
by John Arbash Meinel
Add a test case which exercises this code path. |
367 |
wt.branch.set_last_revision_info(2, 'rev-2b') |
368 |
wt.set_parent_ids(['rev-2b', 'rev-3a']) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
369 |
self.wt_commit(wt, 'rev-3b', rev_id='rev-3b') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
370 |
self.assertFormatterResult("""\ |
3943.4.2
by John Arbash Meinel
Add a test case which exercises this code path. |
371 |
3 Joe Foo\t2005-11-22 [merge] |
372 |
rev-3b
|
|
373 |
||
374 |
2 Joe Foo\t2005-11-22 [merge] |
|
4955.4.19
by Vincent Ladeuil
Less code duplication. |
375 |
rev-2
|
3943.4.2
by John Arbash Meinel
Add a test case which exercises this code path. |
376 |
|
377 |
""", |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
378 |
wt.branch, log.ShortLogFormatter, |
379 |
show_log_kwargs=dict(start_revision=2, end_revision=3)) |
|
3943.4.2
by John Arbash Meinel
Add a test case which exercises this code path. |
380 |
|
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
381 |
def test_short_log_with_tags(self): |
382 |
wt = self._prepare_tree_with_merges(with_tags=True) |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
383 |
self.assertFormatterResult("""\ |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
384 |
3 Joe Foo\t2005-11-22 {v1.0, v1.0rc1} |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
385 |
rev-3
|
386 |
||
387 |
2 Joe Foo\t2005-11-22 {v0.2} [merge] |
|
388 |
rev-2
|
|
389 |
||
390 |
1 Joe Foo\t2005-11-22 |
|
391 |
rev-1
|
|
392 |
||
393 |
""", |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
394 |
wt.branch, log.ShortLogFormatter) |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
395 |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
396 |
def test_short_log_single_merge_revision(self): |
4955.4.19
by Vincent Ladeuil
Less code duplication. |
397 |
wt = self._prepare_tree_with_merges() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
398 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
399 |
rev = revspec.in_history(wt.branch) |
400 |
self.assertFormatterResult("""\ |
|
3947.1.10
by Ian Clatworthy
review feedback from vila |
401 |
1.1.1 Joe Foo\t2005-11-22 |
402 |
rev-merged
|
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
403 |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
404 |
""", |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
405 |
wt.branch, log.ShortLogFormatter, |
406 |
show_log_kwargs=dict(start_revision=rev, end_revision=rev)) |
|
407 |
||
5728.1.1
by Matt Giuca
test_log: Added test cases for the --show-ids switch on 'long' and 'short' log |
408 |
def test_show_ids(self): |
409 |
wt = self.make_branch_and_tree('parent') |
|
410 |
self.build_tree(['parent/f1', 'parent/f2']) |
|
411 |
wt.add(['f1','f2']) |
|
412 |
self.wt_commit(wt, 'first post', rev_id='a') |
|
413 |
child_wt = wt.bzrdir.sprout('child').open_workingtree() |
|
414 |
self.wt_commit(child_wt, 'branch 1 changes', rev_id='b') |
|
415 |
wt.merge_from_branch(child_wt.branch) |
|
416 |
self.wt_commit(wt, 'merge branch 1', rev_id='c') |
|
417 |
self.assertFormatterResult("""\ |
|
418 |
2 Joe Foo\t2005-11-22 [merge] |
|
419 |
revision-id:c
|
|
420 |
merge branch 1
|
|
421 |
||
422 |
1.1.1 Joe Foo\t2005-11-22 |
|
423 |
revision-id:b
|
|
424 |
branch 1 changes
|
|
425 |
||
426 |
1 Joe Foo\t2005-11-22 |
|
427 |
revision-id:a
|
|
428 |
first post
|
|
429 |
||
430 |
""", |
|
431 |
wt.branch, log.ShortLogFormatter, |
|
432 |
formatter_kwargs=dict(levels=0,show_ids=True)) |
|
433 |
||
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
434 |
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
435 |
class TestShortLogFormatterWithMergeRevisions(TestCaseForLogFormatter): |
3947.1.2
by Ian Clatworthy
formatter tests |
436 |
|
437 |
def test_short_merge_revs_log_with_merges(self): |
|
4955.4.19
by Vincent Ladeuil
Less code duplication. |
438 |
wt = self._prepare_tree_with_merges() |
3947.1.7
by Ian Clatworthy
tweak indenting/offsetting for --short given dotted revno lengths |
439 |
# Note that the 1.1.1 indenting is in fact correct given that
|
440 |
# the revision numbers are right justified within 5 characters
|
|
441 |
# for mainline revnos and 9 characters for dotted revnos.
|
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
442 |
self.assertFormatterResult("""\ |
3947.1.2
by Ian Clatworthy
formatter tests |
443 |
2 Joe Foo\t2005-11-22 [merge] |
444 |
rev-2
|
|
445 |
||
3947.1.10
by Ian Clatworthy
review feedback from vila |
446 |
1.1.1 Joe Foo\t2005-11-22 |
447 |
rev-merged
|
|
3947.1.2
by Ian Clatworthy
formatter tests |
448 |
|
449 |
1 Joe Foo\t2005-11-22 |
|
450 |
rev-1
|
|
451 |
||
452 |
""", |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
453 |
wt.branch, log.ShortLogFormatter, |
454 |
formatter_kwargs=dict(levels=0)) |
|
3947.1.2
by Ian Clatworthy
formatter tests |
455 |
|
456 |
def test_short_merge_revs_log_single_merge_revision(self): |
|
4955.4.19
by Vincent Ladeuil
Less code duplication. |
457 |
wt = self._prepare_tree_with_merges() |
3947.1.2
by Ian Clatworthy
formatter tests |
458 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
459 |
rev = revspec.in_history(wt.branch) |
460 |
self.assertFormatterResult("""\ |
|
3947.1.10
by Ian Clatworthy
review feedback from vila |
461 |
1.1.1 Joe Foo\t2005-11-22 |
462 |
rev-merged
|
|
3947.1.2
by Ian Clatworthy
formatter tests |
463 |
|
464 |
""", |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
465 |
wt.branch, log.ShortLogFormatter, |
466 |
formatter_kwargs=dict(levels=0), |
|
467 |
show_log_kwargs=dict(start_revision=rev, end_revision=rev)) |
|
3947.1.2
by Ian Clatworthy
formatter tests |
468 |
|
469 |
||
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
470 |
class TestLongLogFormatter(TestCaseForLogFormatter): |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
471 |
|
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
472 |
def test_verbose_log(self): |
473 |
"""Verbose log includes changed files
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
474 |
|
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
475 |
bug #4676
|
476 |
"""
|
|
4857.4.4
by John Arbash Meinel
One more standard-commit |
477 |
wt = self.make_standard_commit('test_verbose_log', authors=[]) |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
478 |
self.assertFormatterResult('''\ |
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
479 |
------------------------------------------------------------
|
480 |
revno: 1
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
481 |
committer: Lorem Ipsum <test@example.com>
|
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
482 |
branch nick: test_verbose_log
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
483 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
484 |
message:
|
485 |
add a
|
|
486 |
added:
|
|
487 |
a
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
488 |
''', |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
489 |
wt.branch, log.LongLogFormatter, |
4857.4.5
by John Arbash Meinel
We don't need the utf8 option, no test actually wanted to run without it, |
490 |
show_log_kwargs=dict(verbose=True)) |
1185.85.4
by John Arbash Meinel
currently broken, trying to fix things up. |
491 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
492 |
def test_merges_are_indented_by_level(self): |
493 |
wt = self.make_branch_and_tree('parent') |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
494 |
self.wt_commit(wt, 'first post') |
495 |
child_wt = wt.bzrdir.sprout('child').open_workingtree() |
|
496 |
self.wt_commit(child_wt, 'branch 1') |
|
497 |
smallerchild_wt = wt.bzrdir.sprout('smallerchild').open_workingtree() |
|
498 |
self.wt_commit(smallerchild_wt, 'branch 2') |
|
499 |
child_wt.merge_from_branch(smallerchild_wt.branch) |
|
500 |
self.wt_commit(child_wt, 'merge branch 2') |
|
501 |
wt.merge_from_branch(child_wt.branch) |
|
502 |
self.wt_commit(wt, 'merge branch 1') |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
503 |
self.assertFormatterResult("""\ |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
504 |
------------------------------------------------------------
|
4208.2.1
by Ian Clatworthy
merge indicators in log --long |
505 |
revno: 2 [merge]
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
506 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
507 |
branch nick: parent
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
508 |
timestamp: Tue 2005-11-22 00:00:04 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
509 |
message:
|
510 |
merge branch 1
|
|
511 |
------------------------------------------------------------
|
|
4208.2.1
by Ian Clatworthy
merge indicators in log --long |
512 |
revno: 1.1.2 [merge]
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
513 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
514 |
branch nick: child
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
515 |
timestamp: Tue 2005-11-22 00:00:03 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
516 |
message:
|
517 |
merge branch 2
|
|
518 |
------------------------------------------------------------
|
|
3170.3.4
by John Arbash Meinel
Update the tests for the new revision numbering. |
519 |
revno: 1.2.1
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
520 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
521 |
branch nick: smallerchild
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
522 |
timestamp: Tue 2005-11-22 00:00:02 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
523 |
message:
|
524 |
branch 2
|
|
525 |
------------------------------------------------------------
|
|
526 |
revno: 1.1.1
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
527 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
528 |
branch nick: child
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
529 |
timestamp: Tue 2005-11-22 00:00:01 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
530 |
message:
|
531 |
branch 1
|
|
532 |
------------------------------------------------------------
|
|
533 |
revno: 1
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
534 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
535 |
branch nick: parent
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
536 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
537 |
message:
|
538 |
first post
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
539 |
""", |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
540 |
wt.branch, log.LongLogFormatter, |
541 |
formatter_kwargs=dict(levels=0), |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
542 |
show_log_kwargs=dict(verbose=True)) |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
543 |
|
544 |
def test_verbose_merge_revisions_contain_deltas(self): |
|
545 |
wt = self.make_branch_and_tree('parent') |
|
546 |
self.build_tree(['parent/f1', 'parent/f2']) |
|
547 |
wt.add(['f1','f2']) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
548 |
self.wt_commit(wt, 'first post') |
549 |
child_wt = wt.bzrdir.sprout('child').open_workingtree() |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
550 |
os.unlink('child/f1') |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
551 |
self.build_tree_contents([('child/f2', 'hello\n')]) |
552 |
self.wt_commit(child_wt, 'removed f1 and modified f2') |
|
553 |
wt.merge_from_branch(child_wt.branch) |
|
554 |
self.wt_commit(wt, 'merge branch 1') |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
555 |
self.assertFormatterResult("""\ |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
556 |
------------------------------------------------------------
|
4208.2.1
by Ian Clatworthy
merge indicators in log --long |
557 |
revno: 2 [merge]
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
558 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
559 |
branch nick: parent
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
560 |
timestamp: Tue 2005-11-22 00:00:02 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
561 |
message:
|
562 |
merge branch 1
|
|
563 |
removed:
|
|
564 |
f1
|
|
565 |
modified:
|
|
566 |
f2
|
|
567 |
------------------------------------------------------------
|
|
568 |
revno: 1.1.1
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
569 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
570 |
branch nick: child
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
571 |
timestamp: Tue 2005-11-22 00:00:01 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
572 |
message:
|
573 |
removed f1 and modified f2
|
|
574 |
removed:
|
|
575 |
f1
|
|
576 |
modified:
|
|
577 |
f2
|
|
578 |
------------------------------------------------------------
|
|
579 |
revno: 1
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
580 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
581 |
branch nick: parent
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
582 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
583 |
message:
|
584 |
first post
|
|
585 |
added:
|
|
586 |
f1
|
|
587 |
f2
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
588 |
""", |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
589 |
wt.branch, log.LongLogFormatter, |
590 |
formatter_kwargs=dict(levels=0), |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
591 |
show_log_kwargs=dict(verbose=True)) |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
592 |
|
593 |
def test_trailing_newlines(self): |
|
594 |
wt = self.make_branch_and_tree('.') |
|
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
595 |
b = self.make_commits_with_trailing_newlines(wt) |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
596 |
self.assertFormatterResult("""\ |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
597 |
------------------------------------------------------------
|
598 |
revno: 3
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
599 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
600 |
branch nick: test
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
601 |
timestamp: Tue 2005-11-22 00:00:02 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
602 |
message:
|
603 |
single line with trailing newline
|
|
604 |
------------------------------------------------------------
|
|
605 |
revno: 2
|
|
606 |
committer: Joe Foo <joe@foo.com>
|
|
607 |
branch nick: test
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
608 |
timestamp: Tue 2005-11-22 00:00:01 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
609 |
message:
|
610 |
multiline
|
|
611 |
log
|
|
612 |
message
|
|
613 |
------------------------------------------------------------
|
|
614 |
revno: 1
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
615 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
616 |
branch nick: test
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
617 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
618 |
message:
|
619 |
simple log message
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
620 |
""", |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
621 |
b, log.LongLogFormatter) |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
622 |
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
623 |
def test_author_in_log(self): |
624 |
"""Log includes the author name if it's set in
|
|
625 |
the revision properties
|
|
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
626 |
"""
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
627 |
wt = self.make_standard_commit('test_author_log', |
628 |
authors=['John Doe <jdoe@example.com>', |
|
629 |
'Jane Rey <jrey@example.com>']) |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
630 |
self.assertFormatterResult("""\ |
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
631 |
------------------------------------------------------------
|
632 |
revno: 1
|
|
4056.2.3
by James Westby
Use a new "authors" revision property to allow multiple authors |
633 |
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
|
2671.5.4
by Lukáš Lalinsky
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. |
634 |
committer: Lorem Ipsum <test@example.com>
|
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
635 |
branch nick: test_author_log
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
636 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
637 |
message:
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
638 |
add a
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
639 |
""", |
4857.4.5
by John Arbash Meinel
We don't need the utf8 option, no test actually wanted to run without it, |
640 |
wt.branch, log.LongLogFormatter) |
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
641 |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
642 |
def test_properties_in_log(self): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
643 |
"""Log includes the custom properties returned by the registered
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
644 |
handlers.
|
645 |
"""
|
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
646 |
wt = self.make_standard_commit('test_properties_in_log') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
647 |
def trivial_custom_prop_handler(revision): |
648 |
return {'test_prop':'test_value'} |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
649 |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
650 |
# Cleaned up in setUp()
|
651 |
log.properties_handler_registry.register( |
|
652 |
'trivial_custom_prop_handler', |
|
653 |
trivial_custom_prop_handler) |
|
654 |
self.assertFormatterResult("""\ |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
655 |
------------------------------------------------------------
|
656 |
revno: 1
|
|
657 |
test_prop: test_value
|
|
658 |
author: John Doe <jdoe@example.com>
|
|
659 |
committer: Lorem Ipsum <test@example.com>
|
|
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
660 |
branch nick: test_properties_in_log
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
661 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
662 |
message:
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
663 |
add a
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
664 |
""", |
4857.4.5
by John Arbash Meinel
We don't need the utf8 option, no test actually wanted to run without it, |
665 |
wt.branch, log.LongLogFormatter) |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
666 |
|
3976.3.1
by Neil Martinsen-Burrell
Add custom properties handling to short log format |
667 |
def test_properties_in_short_log(self): |
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
668 |
"""Log includes the custom properties returned by the registered
|
3976.3.1
by Neil Martinsen-Burrell
Add custom properties handling to short log format |
669 |
handlers.
|
670 |
"""
|
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
671 |
wt = self.make_standard_commit('test_properties_in_short_log') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
672 |
def trivial_custom_prop_handler(revision): |
673 |
return {'test_prop':'test_value'} |
|
3976.3.1
by Neil Martinsen-Burrell
Add custom properties handling to short log format |
674 |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
675 |
log.properties_handler_registry.register( |
676 |
'trivial_custom_prop_handler', |
|
677 |
trivial_custom_prop_handler) |
|
678 |
self.assertFormatterResult("""\ |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
679 |
1 John Doe\t2005-11-22 |
3976.3.1
by Neil Martinsen-Burrell
Add custom properties handling to short log format |
680 |
test_prop: test_value
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
681 |
add a
|
3976.3.1
by Neil Martinsen-Burrell
Add custom properties handling to short log format |
682 |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
683 |
""", |
684 |
wt.branch, log.ShortLogFormatter) |
|
3976.3.1
by Neil Martinsen-Burrell
Add custom properties handling to short log format |
685 |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
686 |
def test_error_in_properties_handler(self): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
687 |
"""Log includes the custom properties returned by the registered
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
688 |
handlers.
|
689 |
"""
|
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
690 |
wt = self.make_standard_commit('error_in_properties_handler', |
691 |
revprops={'first_prop':'first_value'}) |
|
4857.4.5
by John Arbash Meinel
We don't need the utf8 option, no test actually wanted to run without it, |
692 |
sio = self.make_utf8_encoded_stringio() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
693 |
formatter = log.LongLogFormatter(to_file=sio) |
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
694 |
def trivial_custom_prop_handler(revision): |
695 |
raise StandardError("a test error") |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
696 |
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
697 |
log.properties_handler_registry.register( |
698 |
'trivial_custom_prop_handler', |
|
699 |
trivial_custom_prop_handler) |
|
700 |
self.assertRaises(StandardError, log.show_log, wt.branch, formatter,) |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
701 |
|
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
702 |
def test_properties_handler_bad_argument(self): |
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
703 |
wt = self.make_standard_commit('bad_argument', |
704 |
revprops={'a_prop':'test_value'}) |
|
4857.4.5
by John Arbash Meinel
We don't need the utf8 option, no test actually wanted to run without it, |
705 |
sio = self.make_utf8_encoded_stringio() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
706 |
formatter = log.LongLogFormatter(to_file=sio) |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
707 |
def bad_argument_prop_handler(revision): |
708 |
return {'custom_prop_name':revision.properties['a_prop']} |
|
709 |
||
710 |
log.properties_handler_registry.register( |
|
711 |
'bad_argument_prop_handler', |
|
712 |
bad_argument_prop_handler) |
|
713 |
||
714 |
self.assertRaises(AttributeError, formatter.show_properties, |
|
715 |
'a revision', '') |
|
716 |
||
717 |
revision = wt.branch.repository.get_revision(wt.branch.last_revision()) |
|
718 |
formatter.show_properties(revision, '') |
|
719 |
self.assertEqualDiff('''custom_prop_name: test_value\n''', |
|
720 |
sio.getvalue()) |
|
2671.2.1
by Lukáš Lalinský
Add --author option to 'bzr commit' to record the author's name, if it's different from the committer. |
721 |
|
5728.1.1
by Matt Giuca
test_log: Added test cases for the --show-ids switch on 'long' and 'short' log |
722 |
def test_show_ids(self): |
723 |
wt = self.make_branch_and_tree('parent') |
|
724 |
self.build_tree(['parent/f1', 'parent/f2']) |
|
725 |
wt.add(['f1','f2']) |
|
726 |
self.wt_commit(wt, 'first post', rev_id='a') |
|
727 |
child_wt = wt.bzrdir.sprout('child').open_workingtree() |
|
728 |
self.wt_commit(child_wt, 'branch 1 changes', rev_id='b') |
|
729 |
wt.merge_from_branch(child_wt.branch) |
|
730 |
self.wt_commit(wt, 'merge branch 1', rev_id='c') |
|
731 |
self.assertFormatterResult("""\ |
|
732 |
------------------------------------------------------------
|
|
733 |
revno: 2 [merge]
|
|
734 |
revision-id: c
|
|
735 |
parent: a
|
|
736 |
parent: b
|
|
737 |
committer: Joe Foo <joe@foo.com>
|
|
738 |
branch nick: parent
|
|
739 |
timestamp: Tue 2005-11-22 00:00:02 +0000
|
|
740 |
message:
|
|
741 |
merge branch 1
|
|
742 |
------------------------------------------------------------
|
|
743 |
revno: 1.1.1
|
|
744 |
revision-id: b
|
|
745 |
parent: a
|
|
746 |
committer: Joe Foo <joe@foo.com>
|
|
747 |
branch nick: child
|
|
748 |
timestamp: Tue 2005-11-22 00:00:01 +0000
|
|
749 |
message:
|
|
750 |
branch 1 changes
|
|
751 |
------------------------------------------------------------
|
|
752 |
revno: 1
|
|
753 |
revision-id: a
|
|
754 |
committer: Joe Foo <joe@foo.com>
|
|
755 |
branch nick: parent
|
|
756 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
|
757 |
message:
|
|
758 |
first post
|
|
759 |
""", |
|
760 |
wt.branch, log.LongLogFormatter, |
|
761 |
formatter_kwargs=dict(levels=0,show_ids=True)) |
|
762 |
||
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
763 |
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
764 |
class TestLongLogFormatterWithoutMergeRevisions(TestCaseForLogFormatter): |
3947.1.2
by Ian Clatworthy
formatter tests |
765 |
|
766 |
def test_long_verbose_log(self): |
|
767 |
"""Verbose log includes changed files
|
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
768 |
|
3947.1.2
by Ian Clatworthy
formatter tests |
769 |
bug #4676
|
770 |
"""
|
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
771 |
wt = self.make_standard_commit('test_long_verbose_log', authors=[]) |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
772 |
self.assertFormatterResult("""\ |
3947.1.2
by Ian Clatworthy
formatter tests |
773 |
------------------------------------------------------------
|
774 |
revno: 1
|
|
775 |
committer: Lorem Ipsum <test@example.com>
|
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
776 |
branch nick: test_long_verbose_log
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
777 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
3947.1.2
by Ian Clatworthy
formatter tests |
778 |
message:
|
779 |
add a
|
|
780 |
added:
|
|
781 |
a
|
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
782 |
""", |
783 |
wt.branch, log.LongLogFormatter, |
|
784 |
formatter_kwargs=dict(levels=1), |
|
4857.4.5
by John Arbash Meinel
We don't need the utf8 option, no test actually wanted to run without it, |
785 |
show_log_kwargs=dict(verbose=True)) |
3947.1.2
by Ian Clatworthy
formatter tests |
786 |
|
787 |
def test_long_verbose_contain_deltas(self): |
|
788 |
wt = self.make_branch_and_tree('parent') |
|
789 |
self.build_tree(['parent/f1', 'parent/f2']) |
|
790 |
wt.add(['f1','f2']) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
791 |
self.wt_commit(wt, 'first post') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
792 |
child_wt = wt.bzrdir.sprout('child').open_workingtree() |
3947.1.2
by Ian Clatworthy
formatter tests |
793 |
os.unlink('child/f1') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
794 |
self.build_tree_contents([('child/f2', 'hello\n')]) |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
795 |
self.wt_commit(child_wt, 'removed f1 and modified f2') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
796 |
wt.merge_from_branch(child_wt.branch) |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
797 |
self.wt_commit(wt, 'merge branch 1') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
798 |
self.assertFormatterResult("""\ |
3947.1.2
by Ian Clatworthy
formatter tests |
799 |
------------------------------------------------------------
|
4208.2.1
by Ian Clatworthy
merge indicators in log --long |
800 |
revno: 2 [merge]
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
801 |
committer: Joe Foo <joe@foo.com>
|
3947.1.2
by Ian Clatworthy
formatter tests |
802 |
branch nick: parent
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
803 |
timestamp: Tue 2005-11-22 00:00:02 +0000
|
3947.1.2
by Ian Clatworthy
formatter tests |
804 |
message:
|
805 |
merge branch 1
|
|
806 |
removed:
|
|
807 |
f1
|
|
808 |
modified:
|
|
809 |
f2
|
|
810 |
------------------------------------------------------------
|
|
811 |
revno: 1
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
812 |
committer: Joe Foo <joe@foo.com>
|
3947.1.2
by Ian Clatworthy
formatter tests |
813 |
branch nick: parent
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
814 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
3947.1.2
by Ian Clatworthy
formatter tests |
815 |
message:
|
816 |
first post
|
|
817 |
added:
|
|
818 |
f1
|
|
819 |
f2
|
|
820 |
""", |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
821 |
wt.branch, log.LongLogFormatter, |
822 |
formatter_kwargs=dict(levels=1), |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
823 |
show_log_kwargs=dict(verbose=True)) |
3947.1.2
by Ian Clatworthy
formatter tests |
824 |
|
825 |
def test_long_trailing_newlines(self): |
|
826 |
wt = self.make_branch_and_tree('.') |
|
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
827 |
b = self.make_commits_with_trailing_newlines(wt) |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
828 |
self.assertFormatterResult("""\ |
3947.1.2
by Ian Clatworthy
formatter tests |
829 |
------------------------------------------------------------
|
830 |
revno: 3
|
|
831 |
committer: Joe Foo <joe@foo.com>
|
|
832 |
branch nick: test
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
833 |
timestamp: Tue 2005-11-22 00:00:02 +0000
|
3947.1.2
by Ian Clatworthy
formatter tests |
834 |
message:
|
835 |
single line with trailing newline
|
|
836 |
------------------------------------------------------------
|
|
837 |
revno: 2
|
|
838 |
committer: Joe Foo <joe@foo.com>
|
|
839 |
branch nick: test
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
840 |
timestamp: Tue 2005-11-22 00:00:01 +0000
|
3947.1.2
by Ian Clatworthy
formatter tests |
841 |
message:
|
842 |
multiline
|
|
843 |
log
|
|
844 |
message
|
|
845 |
------------------------------------------------------------
|
|
846 |
revno: 1
|
|
847 |
committer: Joe Foo <joe@foo.com>
|
|
848 |
branch nick: test
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
849 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
3947.1.2
by Ian Clatworthy
formatter tests |
850 |
message:
|
851 |
simple log message
|
|
852 |
""", |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
853 |
b, log.LongLogFormatter, |
854 |
formatter_kwargs=dict(levels=1)) |
|
3947.1.2
by Ian Clatworthy
formatter tests |
855 |
|
856 |
def test_long_author_in_log(self): |
|
857 |
"""Log includes the author name if it's set in
|
|
858 |
the revision properties
|
|
859 |
"""
|
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
860 |
wt = self.make_standard_commit('test_author_log') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
861 |
self.assertFormatterResult("""\ |
3947.1.2
by Ian Clatworthy
formatter tests |
862 |
------------------------------------------------------------
|
863 |
revno: 1
|
|
864 |
author: John Doe <jdoe@example.com>
|
|
865 |
committer: Lorem Ipsum <test@example.com>
|
|
866 |
branch nick: test_author_log
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
867 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
3947.1.2
by Ian Clatworthy
formatter tests |
868 |
message:
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
869 |
add a
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
870 |
""", |
871 |
wt.branch, log.LongLogFormatter, |
|
872 |
formatter_kwargs=dict(levels=1)) |
|
3947.1.2
by Ian Clatworthy
formatter tests |
873 |
|
874 |
def test_long_properties_in_log(self): |
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
875 |
"""Log includes the custom properties returned by the registered
|
3947.1.2
by Ian Clatworthy
formatter tests |
876 |
handlers.
|
877 |
"""
|
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
878 |
wt = self.make_standard_commit('test_properties_in_log') |
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
879 |
def trivial_custom_prop_handler(revision): |
880 |
return {'test_prop':'test_value'} |
|
3947.1.2
by Ian Clatworthy
formatter tests |
881 |
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
882 |
log.properties_handler_registry.register( |
883 |
'trivial_custom_prop_handler', |
|
884 |
trivial_custom_prop_handler) |
|
885 |
self.assertFormatterResult("""\ |
|
3947.1.2
by Ian Clatworthy
formatter tests |
886 |
------------------------------------------------------------
|
887 |
revno: 1
|
|
888 |
test_prop: test_value
|
|
889 |
author: John Doe <jdoe@example.com>
|
|
890 |
committer: Lorem Ipsum <test@example.com>
|
|
891 |
branch nick: test_properties_in_log
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
892 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
3947.1.2
by Ian Clatworthy
formatter tests |
893 |
message:
|
4857.4.2
by John Arbash Meinel
Add a 'make_standard_commit' helper, to remove more code duplication. |
894 |
add a
|
4857.4.1
by John Arbash Meinel
Start cleaning up test_log. |
895 |
""", |
896 |
wt.branch, log.LongLogFormatter, |
|
897 |
formatter_kwargs=dict(levels=1)) |
|
3947.1.2
by Ian Clatworthy
formatter tests |
898 |
|
899 |
||
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
900 |
class TestLineLogFormatter(TestCaseForLogFormatter): |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
901 |
|
1704.2.20
by Martin Pool
log --line shows revision numbers (Alexander) |
902 |
def test_line_log(self): |
903 |
"""Line log should show revno
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
904 |
|
1704.2.20
by Martin Pool
log --line shows revision numbers (Alexander) |
905 |
bug #5162
|
906 |
"""
|
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
907 |
wt = self.make_standard_commit('test-line-log', |
908 |
committer='Line-Log-Formatter Tester <test@line.log>', |
|
909 |
authors=[]) |
|
910 |
self.assertFormatterResult("""\ |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
911 |
1: Line-Log-Formatte... 2005-11-22 add a
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
912 |
""", |
913 |
wt.branch, log.LineLogFormatter) |
|
1756.2.20
by Aaron Bentley
Optimize log formats that don't show merges |
914 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
915 |
def test_trailing_newlines(self): |
916 |
wt = self.make_branch_and_tree('.') |
|
4955.4.1
by Vincent Ladeuil
Refactor the function into an helper. |
917 |
b = self.make_commits_with_trailing_newlines(wt) |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
918 |
self.assertFormatterResult("""\ |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
919 |
3: Joe Foo 2005-11-22 single line with trailing newline
|
920 |
2: Joe Foo 2005-11-22 multiline
|
|
921 |
1: Joe Foo 2005-11-22 simple log message
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
922 |
""", |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
923 |
b, log.LineLogFormatter) |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
924 |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
925 |
def test_line_log_single_merge_revision(self): |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
926 |
wt = self._prepare_tree_with_merges() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
927 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
928 |
rev = revspec.in_history(wt.branch) |
929 |
self.assertFormatterResult("""\ |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
930 |
1.1.1: Joe Foo 2005-11-22 rev-merged
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
931 |
""", |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
932 |
wt.branch, log.LineLogFormatter, |
933 |
show_log_kwargs=dict(start_revision=rev, end_revision=rev)) |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
934 |
|
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
935 |
def test_line_log_with_tags(self): |
936 |
wt = self._prepare_tree_with_merges(with_tags=True) |
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
937 |
self.assertFormatterResult("""\ |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
938 |
3: Joe Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
|
3983.2.1
by Neil Martinsen-Burrell
add merge indication to the line format |
939 |
2: Joe Foo 2005-11-22 [merge] {v0.2} rev-2 |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
940 |
1: Joe Foo 2005-11-22 rev-1
|
941 |
""", |
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
942 |
wt.branch, log.LineLogFormatter) |
943 |
||
944 |
||
945 |
class TestLineLogFormatterWithMergeRevisions(TestCaseForLogFormatter): |
|
3947.1.2
by Ian Clatworthy
formatter tests |
946 |
|
947 |
def test_line_merge_revs_log(self): |
|
948 |
"""Line log should show revno
|
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
949 |
|
3947.1.2
by Ian Clatworthy
formatter tests |
950 |
bug #5162
|
951 |
"""
|
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
952 |
wt = self.make_standard_commit('test-line-log', |
953 |
committer='Line-Log-Formatter Tester <test@line.log>', |
|
954 |
authors=[]) |
|
955 |
self.assertFormatterResult("""\ |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
956 |
1: Line-Log-Formatte... 2005-11-22 add a
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
957 |
""", |
958 |
wt.branch, log.LineLogFormatter) |
|
3947.1.2
by Ian Clatworthy
formatter tests |
959 |
|
960 |
def test_line_merge_revs_log_single_merge_revision(self): |
|
4955.4.19
by Vincent Ladeuil
Less code duplication. |
961 |
wt = self._prepare_tree_with_merges() |
3947.1.2
by Ian Clatworthy
formatter tests |
962 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
963 |
rev = revspec.in_history(wt.branch) |
964 |
self.assertFormatterResult("""\ |
|
3947.1.2
by Ian Clatworthy
formatter tests |
965 |
1.1.1: Joe Foo 2005-11-22 rev-merged
|
966 |
""", |
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
967 |
wt.branch, log.LineLogFormatter, |
968 |
formatter_kwargs=dict(levels=0), |
|
969 |
show_log_kwargs=dict(start_revision=rev, end_revision=rev)) |
|
3947.1.2
by Ian Clatworthy
formatter tests |
970 |
|
971 |
def test_line_merge_revs_log_with_merges(self): |
|
4955.4.19
by Vincent Ladeuil
Less code duplication. |
972 |
wt = self._prepare_tree_with_merges() |
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
973 |
self.assertFormatterResult("""\ |
3983.2.1
by Neil Martinsen-Burrell
add merge indication to the line format |
974 |
2: Joe Foo 2005-11-22 [merge] rev-2
|
3947.1.2
by Ian Clatworthy
formatter tests |
975 |
1.1.1: Joe Foo 2005-11-22 rev-merged
|
976 |
1: Joe Foo 2005-11-22 rev-1
|
|
977 |
""", |
|
4857.4.3
by John Arbash Meinel
Handle LineLogFormatter |
978 |
wt.branch, log.LineLogFormatter, |
979 |
formatter_kwargs=dict(levels=0)) |
|
980 |
||
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
981 |
|
4081.2.4
by Martin von Gagern
Added basic test cases for GNU Changelog format. |
982 |
class TestGnuChangelogFormatter(TestCaseForLogFormatter): |
983 |
||
984 |
def test_gnu_changelog(self): |
|
985 |
wt = self.make_standard_commit('nicky', authors=[]) |
|
986 |
self.assertFormatterResult('''\ |
|
987 |
2005-11-22 Lorem Ipsum <test@example.com>
|
|
988 |
||
989 |
\tadd a |
|
990 |
||
991 |
''', |
|
992 |
wt.branch, log.GnuChangelogLogFormatter) |
|
993 |
||
994 |
def test_with_authors(self): |
|
995 |
wt = self.make_standard_commit('nicky', |
|
996 |
authors=['Fooa Fooz <foo@example.com>', |
|
997 |
'Bari Baro <bar@example.com>']) |
|
998 |
self.assertFormatterResult('''\ |
|
999 |
2005-11-22 Fooa Fooz <foo@example.com>
|
|
1000 |
||
1001 |
\tadd a |
|
1002 |
||
1003 |
''', |
|
1004 |
wt.branch, log.GnuChangelogLogFormatter) |
|
1005 |
||
1006 |
def test_verbose(self): |
|
1007 |
wt = self.make_standard_commit('nicky') |
|
1008 |
self.assertFormatterResult('''\ |
|
1009 |
2005-11-22 John Doe <jdoe@example.com>
|
|
1010 |
||
1011 |
\t* a: |
|
1012 |
||
1013 |
\tadd a |
|
1014 |
||
1015 |
''', |
|
1016 |
wt.branch, log.GnuChangelogLogFormatter, |
|
1017 |
show_log_kwargs=dict(verbose=True)) |
|
1018 |
||
1551.17.2
by Aaron Bentley
Stop showing deltas in pull -v output |
1019 |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1020 |
class TestShowChangedRevisions(tests.TestCaseWithTransport): |
1551.17.2
by Aaron Bentley
Stop showing deltas in pull -v output |
1021 |
|
1022 |
def test_show_changed_revisions_verbose(self): |
|
1023 |
tree = self.make_branch_and_tree('tree_a') |
|
1024 |
self.build_tree(['tree_a/foo']) |
|
1025 |
tree.add('foo') |
|
1026 |
tree.commit('bar', rev_id='bar-id') |
|
2717.1.1
by Lukáš Lalinsky
Use UTF-8 encoded StringIO for log tests to avoid failures on non-ASCII committer names. |
1027 |
s = self.make_utf8_encoded_stringio() |
1551.17.2
by Aaron Bentley
Stop showing deltas in pull -v output |
1028 |
log.show_changed_revisions(tree.branch, [], ['bar-id'], s) |
1029 |
self.assertContainsRe(s.getvalue(), 'bar') |
|
1030 |
self.assertNotContainsRe(s.getvalue(), 'foo') |
|
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1031 |
|
1032 |
||
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1033 |
class TestLogFormatter(tests.TestCase): |
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1034 |
|
4955.4.15
by Vincent Ladeuil
Remove duplicated code. |
1035 |
def setUp(self): |
1036 |
super(TestLogFormatter, self).setUp() |
|
1037 |
self.rev = revision.Revision('a-id') |
|
1038 |
self.lf = log.LogFormatter(None) |
|
1039 |
||
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1040 |
def test_short_committer(self): |
4955.4.15
by Vincent Ladeuil
Remove duplicated code. |
1041 |
def assertCommitter(expected, committer): |
1042 |
self.rev.committer = committer |
|
1043 |
self.assertEqual(expected, self.lf.short_committer(self.rev)) |
|
1044 |
||
1045 |
assertCommitter('John Doe', 'John Doe <jdoe@example.com>') |
|
1046 |
assertCommitter('John Smith', 'John Smith <jsmith@example.com>') |
|
1047 |
assertCommitter('John Smith', 'John Smith') |
|
1048 |
assertCommitter('jsmith@example.com', 'jsmith@example.com') |
|
1049 |
assertCommitter('jsmith@example.com', '<jsmith@example.com>') |
|
1050 |
assertCommitter('John Smith', 'John Smith jsmith@example.com') |
|
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1051 |
|
1052 |
def test_short_author(self): |
|
4955.4.15
by Vincent Ladeuil
Remove duplicated code. |
1053 |
def assertAuthor(expected, author): |
1054 |
self.rev.properties['author'] = author |
|
1055 |
self.assertEqual(expected, self.lf.short_author(self.rev)) |
|
1056 |
||
1057 |
assertAuthor('John Smith', 'John Smith <jsmith@example.com>') |
|
1058 |
assertAuthor('John Smith', 'John Smith') |
|
1059 |
assertAuthor('jsmith@example.com', 'jsmith@example.com') |
|
1060 |
assertAuthor('jsmith@example.com', '<jsmith@example.com>') |
|
1061 |
assertAuthor('John Smith', 'John Smith jsmith@example.com') |
|
1062 |
||
1063 |
def test_short_author_from_committer(self): |
|
1064 |
self.rev.committer = 'John Doe <jdoe@example.com>' |
|
1065 |
self.assertEqual('John Doe', self.lf.short_author(self.rev)) |
|
1066 |
||
1067 |
def test_short_author_from_authors(self): |
|
1068 |
self.rev.properties['authors'] = ('John Smith <jsmith@example.com>\n' |
|
1069 |
'Jane Rey <jrey@example.com>') |
|
1070 |
self.assertEqual('John Smith', self.lf.short_author(self.rev)) |
|
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1071 |
|
1072 |
||
1073 |
class TestReverseByDepth(tests.TestCase): |
|
1074 |
"""Test reverse_by_depth behavior.
|
|
1075 |
||
1076 |
This is used to present revisions in forward (oldest first) order in a nice
|
|
1077 |
layout.
|
|
1078 |
||
1079 |
The tests use lighter revision description to ease reading.
|
|
1080 |
"""
|
|
1081 |
||
1082 |
def assertReversed(self, forward, backward): |
|
1083 |
# Transform the descriptions to suit the API: tests use (revno, depth),
|
|
1084 |
# while the API expects (revid, revno, depth)
|
|
1085 |
def complete_revisions(l): |
|
1086 |
"""Transform the description to suit the API.
|
|
1087 |
||
1088 |
Tests use (revno, depth) whil the API expects (revid, revno, depth).
|
|
1089 |
Since the revid is arbitrary, we just duplicate revno
|
|
1090 |
"""
|
|
1091 |
return [ (r, r, d) for r, d in l] |
|
1092 |
forward = complete_revisions(forward) |
|
1093 |
backward= complete_revisions(backward) |
|
1094 |
self.assertEqual(forward, log.reverse_by_depth(backward)) |
|
1095 |
||
1096 |
||
1097 |
def test_mainline_revisions(self): |
|
1098 |
self.assertReversed([( '1', 0), ('2', 0)], |
|
1099 |
[('2', 0), ('1', 0)]) |
|
1100 |
||
1101 |
def test_merged_revisions(self): |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1102 |
self.assertReversed([('1', 0), ('2', 0), ('2.2', 1), ('2.1', 1),], |
1103 |
[('2', 0), ('2.1', 1), ('2.2', 1), ('1', 0),]) |
|
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1104 |
def test_shifted_merged_revisions(self): |
1105 |
"""Test irregular layout.
|
|
1106 |
||
1107 |
Requesting revisions touching a file can produce "holes" in the depths.
|
|
1108 |
"""
|
|
1109 |
self.assertReversed([('1', 0), ('2', 0), ('1.1', 2), ('1.2', 2),], |
|
1110 |
[('2', 0), ('1.2', 2), ('1.1', 2), ('1', 0),]) |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1111 |
|
1112 |
def test_merged_without_child_revisions(self): |
|
1113 |
"""Test irregular layout.
|
|
1114 |
||
1115 |
Revision ranges can produce "holes" in the depths.
|
|
1116 |
"""
|
|
1117 |
# When a revision of higher depth doesn't follow one of lower depth, we
|
|
1118 |
# assume a lower depth one is virtually there
|
|
1119 |
self.assertReversed([('1', 2), ('2', 2), ('3', 3), ('4', 4)], |
|
1120 |
[('4', 4), ('3', 3), ('2', 2), ('1', 2),]) |
|
1121 |
# So we get the same order after reversing below even if the original
|
|
1122 |
# revisions are not in the same order.
|
|
1123 |
self.assertReversed([('1', 2), ('2', 2), ('3', 3), ('4', 4)], |
|
1124 |
[('3', 3), ('4', 4), ('2', 2), ('1', 2),]) |
|
3848.1.6
by Aaron Bentley
Implement get_history_change |
1125 |
|
1126 |
||
3848.1.8
by Aaron Bentley
Implement basic show_branch_change |
1127 |
class TestHistoryChange(tests.TestCaseWithTransport): |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1128 |
|
1129 |
def setup_a_tree(self): |
|
1130 |
tree = self.make_branch_and_tree('tree') |
|
1131 |
tree.lock_write() |
|
1132 |
self.addCleanup(tree.unlock) |
|
1133 |
tree.commit('1a', rev_id='1a') |
|
1134 |
tree.commit('2a', rev_id='2a') |
|
1135 |
tree.commit('3a', rev_id='3a') |
|
1136 |
return tree |
|
1137 |
||
1138 |
def setup_ab_tree(self): |
|
1139 |
tree = self.setup_a_tree() |
|
1140 |
tree.set_last_revision('1a') |
|
1141 |
tree.branch.set_last_revision_info(1, '1a') |
|
1142 |
tree.commit('2b', rev_id='2b') |
|
1143 |
tree.commit('3b', rev_id='3b') |
|
1144 |
return tree |
|
1145 |
||
1146 |
def setup_ac_tree(self): |
|
1147 |
tree = self.setup_a_tree() |
|
1148 |
tree.set_last_revision(revision.NULL_REVISION) |
|
1149 |
tree.branch.set_last_revision_info(0, revision.NULL_REVISION) |
|
1150 |
tree.commit('1c', rev_id='1c') |
|
1151 |
tree.commit('2c', rev_id='2c') |
|
1152 |
tree.commit('3c', rev_id='3c') |
|
1153 |
return tree |
|
1154 |
||
1155 |
def test_all_new(self): |
|
1156 |
tree = self.setup_ab_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1157 |
old, new = log.get_history_change('1a', '3a', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1158 |
self.assertEqual([], old) |
1159 |
self.assertEqual(['2a', '3a'], new) |
|
1160 |
||
1161 |
def test_all_old(self): |
|
1162 |
tree = self.setup_ab_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1163 |
old, new = log.get_history_change('3a', '1a', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1164 |
self.assertEqual([], new) |
1165 |
self.assertEqual(['2a', '3a'], old) |
|
1166 |
||
1167 |
def test_null_old(self): |
|
1168 |
tree = self.setup_ab_tree() |
|
1169 |
old, new = log.get_history_change(revision.NULL_REVISION, |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1170 |
'3a', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1171 |
self.assertEqual([], old) |
1172 |
self.assertEqual(['1a', '2a', '3a'], new) |
|
1173 |
||
1174 |
def test_null_new(self): |
|
1175 |
tree = self.setup_ab_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1176 |
old, new = log.get_history_change('3a', revision.NULL_REVISION, |
1177 |
tree.branch.repository) |
|
3848.1.6
by Aaron Bentley
Implement get_history_change |
1178 |
self.assertEqual([], new) |
1179 |
self.assertEqual(['1a', '2a', '3a'], old) |
|
1180 |
||
1181 |
def test_diverged(self): |
|
1182 |
tree = self.setup_ab_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1183 |
old, new = log.get_history_change('3a', '3b', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1184 |
self.assertEqual(old, ['2a', '3a']) |
1185 |
self.assertEqual(new, ['2b', '3b']) |
|
1186 |
||
1187 |
def test_unrelated(self): |
|
1188 |
tree = self.setup_ac_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1189 |
old, new = log.get_history_change('3a', '3c', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1190 |
self.assertEqual(old, ['1a', '2a', '3a']) |
1191 |
self.assertEqual(new, ['1c', '2c', '3c']) |
|
3848.1.8
by Aaron Bentley
Implement basic show_branch_change |
1192 |
|
1193 |
def test_show_branch_change(self): |
|
1194 |
tree = self.setup_ab_tree() |
|
1195 |
s = StringIO() |
|
3848.1.12
by Aaron Bentley
Fix test parameter order |
1196 |
log.show_branch_change(tree.branch, s, 3, '3a') |
3848.1.8
by Aaron Bentley
Implement basic show_branch_change |
1197 |
self.assertContainsRe(s.getvalue(), |
1198 |
'[*]{60}\nRemoved Revisions:\n(.|\n)*2a(.|\n)*3a(.|\n)*' |
|
1199 |
'[*]{60}\n\nAdded Revisions:\n(.|\n)*2b(.|\n)*3b') |
|
1200 |
||
1201 |
def test_show_branch_change_no_change(self): |
|
1202 |
tree = self.setup_ab_tree() |
|
1203 |
s = StringIO() |
|
3848.1.12
by Aaron Bentley
Fix test parameter order |
1204 |
log.show_branch_change(tree.branch, s, 3, '3b') |
3848.1.8
by Aaron Bentley
Implement basic show_branch_change |
1205 |
self.assertEqual(s.getvalue(), |
1206 |
'Nothing seems to have changed\n') |
|
1207 |
||
3848.1.9
by Aaron Bentley
new/old sections are omitted as appropriate. |
1208 |
def test_show_branch_change_no_old(self): |
1209 |
tree = self.setup_ab_tree() |
|
1210 |
s = StringIO() |
|
3848.1.12
by Aaron Bentley
Fix test parameter order |
1211 |
log.show_branch_change(tree.branch, s, 2, '2b') |
3848.1.9
by Aaron Bentley
new/old sections are omitted as appropriate. |
1212 |
self.assertContainsRe(s.getvalue(), 'Added Revisions:') |
1213 |
self.assertNotContainsRe(s.getvalue(), 'Removed Revisions:') |
|
1214 |
||
1215 |
def test_show_branch_change_no_new(self): |
|
1216 |
tree = self.setup_ab_tree() |
|
1217 |
tree.branch.set_last_revision_info(2, '2b') |
|
1218 |
s = StringIO() |
|
3848.1.12
by Aaron Bentley
Fix test parameter order |
1219 |
log.show_branch_change(tree.branch, s, 3, '3b') |
3848.1.9
by Aaron Bentley
new/old sections are omitted as appropriate. |
1220 |
self.assertContainsRe(s.getvalue(), 'Removed Revisions:') |
1221 |
self.assertNotContainsRe(s.getvalue(), 'Added Revisions:') |
|
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1222 |
|
5728.5.2
by Matt Giuca
test_log: Split new test cases for this branch out into a separate class, |
1223 |
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1224 |
class TestRevisionNotInBranch(TestCaseForLogFormatter): |
5728.5.2
by Matt Giuca
test_log: Split new test cases for this branch out into a separate class, |
1225 |
|
1226 |
def setup_a_tree(self): |
|
1227 |
tree = self.make_branch_and_tree('tree') |
|
1228 |
tree.lock_write() |
|
1229 |
self.addCleanup(tree.unlock) |
|
5728.5.3
by Matt Giuca
test_log: TestRevisionNotInBranch commits now have more metadata. |
1230 |
kwargs = { |
1231 |
'committer': 'Joe Foo <joe@foo.com>', |
|
1232 |
'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000 |
|
5728.5.10
by Andrew Bennetts
Use UTC, not system time zone, for the new log tests to get predictable output. |
1233 |
'timezone': 0, # UTC |
5728.5.3
by Matt Giuca
test_log: TestRevisionNotInBranch commits now have more metadata. |
1234 |
}
|
1235 |
tree.commit('commit 1a', rev_id='1a', **kwargs) |
|
1236 |
tree.commit('commit 2a', rev_id='2a', **kwargs) |
|
1237 |
tree.commit('commit 3a', rev_id='3a', **kwargs) |
|
5728.5.2
by Matt Giuca
test_log: Split new test cases for this branch out into a separate class, |
1238 |
return tree |
1239 |
||
1240 |
def setup_ab_tree(self): |
|
1241 |
tree = self.setup_a_tree() |
|
1242 |
tree.set_last_revision('1a') |
|
1243 |
tree.branch.set_last_revision_info(1, '1a') |
|
5728.5.3
by Matt Giuca
test_log: TestRevisionNotInBranch commits now have more metadata. |
1244 |
kwargs = { |
1245 |
'committer': 'Joe Foo <joe@foo.com>', |
|
1246 |
'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000 |
|
5728.5.10
by Andrew Bennetts
Use UTC, not system time zone, for the new log tests to get predictable output. |
1247 |
'timezone': 0, # UTC |
5728.5.3
by Matt Giuca
test_log: TestRevisionNotInBranch commits now have more metadata. |
1248 |
}
|
1249 |
tree.commit('commit 2b', rev_id='2b', **kwargs) |
|
1250 |
tree.commit('commit 3b', rev_id='3b', **kwargs) |
|
5728.5.2
by Matt Giuca
test_log: Split new test cases for this branch out into a separate class, |
1251 |
return tree |
1252 |
||
1253 |
def test_one_revision(self): |
|
5728.5.1
by Matt Giuca
log no longer raises NoSuchRevision against revisions in the |
1254 |
tree = self.setup_ab_tree() |
1255 |
lf = LogCatcher() |
|
1256 |
rev = revisionspec.RevisionInfo(tree.branch, None, '3a') |
|
1257 |
log.show_log(tree.branch, lf, verbose=True, start_revision=rev, |
|
1258 |
end_revision=rev) |
|
1259 |
self.assertEqual(1, len(lf.revisions)) |
|
5728.5.5
by Matt Giuca
log: If a revision is not in the branch, it now sets its revno to None |
1260 |
self.assertEqual(None, lf.revisions[0].revno) # Out-of-branch |
1261 |
self.assertEqual('3a', lf.revisions[0].rev.revision_id) |
|
5728.5.1
by Matt Giuca
log no longer raises NoSuchRevision against revisions in the |
1262 |
|
5728.5.2
by Matt Giuca
test_log: Split new test cases for this branch out into a separate class, |
1263 |
def test_many_revisions(self): |
5728.5.1
by Matt Giuca
log no longer raises NoSuchRevision against revisions in the |
1264 |
tree = self.setup_ab_tree() |
1265 |
lf = LogCatcher() |
|
1266 |
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a') |
|
1267 |
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a') |
|
1268 |
log.show_log(tree.branch, lf, verbose=True, start_revision=start_rev, |
|
1269 |
end_revision=end_rev) |
|
1270 |
self.assertEqual(3, len(lf.revisions)) |
|
5728.5.5
by Matt Giuca
log: If a revision is not in the branch, it now sets its revno to None |
1271 |
self.assertEqual(None, lf.revisions[0].revno) # Out-of-branch |
1272 |
self.assertEqual('3a', lf.revisions[0].rev.revision_id) |
|
1273 |
self.assertEqual(None, lf.revisions[1].revno) # Out-of-branch |
|
1274 |
self.assertEqual('2a', lf.revisions[1].rev.revision_id) |
|
5728.5.1
by Matt Giuca
log no longer raises NoSuchRevision against revisions in the |
1275 |
self.assertEqual('1', lf.revisions[2].revno) # In-branch |
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1276 |
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1277 |
def test_long_format(self): |
1278 |
tree = self.setup_ab_tree() |
|
1279 |
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a') |
|
1280 |
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a') |
|
1281 |
self.assertFormatterResult("""\ |
|
1282 |
------------------------------------------------------------
|
|
5728.5.6
by Matt Giuca
log: 'long' and 'short' log formats now always show the revision-id for any |
1283 |
revision-id: 3a
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1284 |
committer: Joe Foo <joe@foo.com>
|
1285 |
branch nick: tree
|
|
5728.5.10
by Andrew Bennetts
Use UTC, not system time zone, for the new log tests to get predictable output. |
1286 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1287 |
message:
|
1288 |
commit 3a
|
|
1289 |
------------------------------------------------------------
|
|
5728.5.6
by Matt Giuca
log: 'long' and 'short' log formats now always show the revision-id for any |
1290 |
revision-id: 2a
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1291 |
committer: Joe Foo <joe@foo.com>
|
1292 |
branch nick: tree
|
|
5728.5.10
by Andrew Bennetts
Use UTC, not system time zone, for the new log tests to get predictable output. |
1293 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1294 |
message:
|
1295 |
commit 2a
|
|
1296 |
------------------------------------------------------------
|
|
1297 |
revno: 1
|
|
1298 |
committer: Joe Foo <joe@foo.com>
|
|
1299 |
branch nick: tree
|
|
5728.5.10
by Andrew Bennetts
Use UTC, not system time zone, for the new log tests to get predictable output. |
1300 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1301 |
message:
|
1302 |
commit 1a
|
|
1303 |
""", |
|
1304 |
tree.branch, log.LongLogFormatter, show_log_kwargs={ |
|
1305 |
'start_revision': start_rev, 'end_revision': end_rev |
|
1306 |
})
|
|
1307 |
||
1308 |
def test_short_format(self): |
|
1309 |
tree = self.setup_ab_tree() |
|
1310 |
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a') |
|
1311 |
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a') |
|
1312 |
self.assertFormatterResult("""\ |
|
5728.5.5
by Matt Giuca
log: If a revision is not in the branch, it now sets its revno to None |
1313 |
Joe Foo\t2005-11-22 |
5728.5.6
by Matt Giuca
log: 'long' and 'short' log formats now always show the revision-id for any |
1314 |
revision-id:3a
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1315 |
commit 3a
|
1316 |
||
5728.5.5
by Matt Giuca
log: If a revision is not in the branch, it now sets its revno to None |
1317 |
Joe Foo\t2005-11-22 |
5728.5.6
by Matt Giuca
log: 'long' and 'short' log formats now always show the revision-id for any |
1318 |
revision-id:2a
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1319 |
commit 2a
|
1320 |
||
1321 |
1 Joe Foo\t2005-11-22 |
|
1322 |
commit 1a
|
|
1323 |
||
1324 |
""", |
|
1325 |
tree.branch, log.ShortLogFormatter, show_log_kwargs={ |
|
1326 |
'start_revision': start_rev, 'end_revision': end_rev |
|
1327 |
})
|
|
1328 |
||
1329 |
def test_line_format(self): |
|
1330 |
tree = self.setup_ab_tree() |
|
1331 |
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a') |
|
1332 |
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a') |
|
1333 |
self.assertFormatterResult("""\ |
|
5728.5.5
by Matt Giuca
log: If a revision is not in the branch, it now sets its revno to None |
1334 |
Joe Foo 2005-11-22 commit 3a
|
1335 |
Joe Foo 2005-11-22 commit 2a
|
|
5728.5.4
by Matt Giuca
test_log: TestRevisionNotInBranch: Added three new test cases, testing the |
1336 |
1: Joe Foo 2005-11-22 commit 1a
|
1337 |
""", |
|
1338 |
tree.branch, log.LineLogFormatter, show_log_kwargs={ |
|
1339 |
'start_revision': start_rev, 'end_revision': end_rev |
|
1340 |
})
|
|
1341 |
||
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1342 |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1343 |
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin): |
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1344 |
|
1345 |
def setUp(self): |
|
6552.1.4
by Vincent Ladeuil
Remaining tests matching setup(self) that can be rewritten with super(). |
1346 |
super(TestLogWithBugs, self).setUp() |
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1347 |
log.properties_handler_registry.register( |
1348 |
'bugs_properties_handler', |
|
1349 |
log._bugs_properties_handler) |
|
1350 |
||
4921.2.2
by Neil Martinsen-Burrell
from review comments: improve splitting, add test that handler is present, use build_tree in tests |
1351 |
def make_commits_with_bugs(self): |
1352 |
"""Helper method for LogFormatter tests"""
|
|
1353 |
tree = self.make_branch_and_tree(u'.') |
|
1354 |
self.build_tree(['a', 'b']) |
|
1355 |
tree.add('a') |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1356 |
self.wt_commit(tree, 'simple log message', rev_id='a1', |
1357 |
revprops={'bugs': 'test://bug/id fixed'}) |
|
4921.2.2
by Neil Martinsen-Burrell
from review comments: improve splitting, add test that handler is present, use build_tree in tests |
1358 |
tree.add('b') |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1359 |
self.wt_commit(tree, 'multiline\nlog\nmessage\n', rev_id='a2', |
1360 |
authors=['Joe Bar <joe@bar.com>'], |
|
1361 |
revprops={'bugs': 'test://bug/id fixed\n' |
|
1362 |
'test://bug/2 fixed'}) |
|
4921.2.2
by Neil Martinsen-Burrell
from review comments: improve splitting, add test that handler is present, use build_tree in tests |
1363 |
return tree |
1364 |
||
1365 |
||
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1366 |
def test_long_bugs(self): |
4921.2.2
by Neil Martinsen-Burrell
from review comments: improve splitting, add test that handler is present, use build_tree in tests |
1367 |
tree = self.make_commits_with_bugs() |
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1368 |
self.assertFormatterResult("""\ |
1369 |
------------------------------------------------------------
|
|
1370 |
revno: 2
|
|
6143.1.8
by Jonathan Riddell
fix log formatting of bug line |
1371 |
fixes bugs: test://bug/id test://bug/2
|
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1372 |
author: Joe Bar <joe@bar.com>
|
1373 |
committer: Joe Foo <joe@foo.com>
|
|
1374 |
branch nick: work
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1375 |
timestamp: Tue 2005-11-22 00:00:01 +0000
|
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1376 |
message:
|
1377 |
multiline
|
|
1378 |
log
|
|
1379 |
message
|
|
1380 |
------------------------------------------------------------
|
|
1381 |
revno: 1
|
|
6143.1.4
by Jonathan Riddell
update tests |
1382 |
fixes bug: test://bug/id
|
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1383 |
committer: Joe Foo <joe@foo.com>
|
1384 |
branch nick: work
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1385 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1386 |
message:
|
1387 |
simple log message
|
|
1388 |
""", |
|
1389 |
tree.branch, log.LongLogFormatter) |
|
1390 |
||
1391 |
def test_short_bugs(self): |
|
4921.2.2
by Neil Martinsen-Burrell
from review comments: improve splitting, add test that handler is present, use build_tree in tests |
1392 |
tree = self.make_commits_with_bugs() |
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1393 |
self.assertFormatterResult("""\ |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1394 |
2 Joe Bar\t2005-11-22 |
6143.1.4
by Jonathan Riddell
update tests |
1395 |
fixes bugs: test://bug/id test://bug/2
|
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1396 |
multiline
|
1397 |
log
|
|
1398 |
message
|
|
1399 |
||
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1400 |
1 Joe Foo\t2005-11-22 |
6143.1.4
by Jonathan Riddell
update tests |
1401 |
fixes bug: test://bug/id
|
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1402 |
simple log message
|
1403 |
||
1404 |
""", |
|
1405 |
tree.branch, log.ShortLogFormatter) |
|
1406 |
||
1407 |
def test_wrong_bugs_property(self): |
|
1408 |
tree = self.make_branch_and_tree(u'.') |
|
1409 |
self.build_tree(['foo']) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1410 |
self.wt_commit(tree, 'simple log message', rev_id='a1', |
1411 |
revprops={'bugs': 'test://bug/id invalid_value'}) |
|
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1412 |
self.assertFormatterResult("""\ |
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
1413 |
1 Joe Foo\t2005-11-22 |
4921.2.1
by Neil Martinsen-Burrell
include bug fixes in log output |
1414 |
simple log message
|
1415 |
||
1416 |
""", |
|
1417 |
tree.branch, log.ShortLogFormatter) |
|
4921.2.2
by Neil Martinsen-Burrell
from review comments: improve splitting, add test that handler is present, use build_tree in tests |
1418 |
|
1419 |
def test_bugs_handler_present(self): |
|
1420 |
self.properties_handler_registry.get('bugs_properties_handler') |
|
4081.3.5
by Martin von Gagern
NEWS and test cases for bzr log --authors. |
1421 |
|
1422 |
||
1423 |
class TestLogForAuthors(TestCaseForLogFormatter): |
|
1424 |
||
1425 |
def setUp(self): |
|
6552.1.4
by Vincent Ladeuil
Remaining tests matching setup(self) that can be rewritten with super(). |
1426 |
super(TestLogForAuthors, self).setUp() |
4081.3.5
by Martin von Gagern
NEWS and test cases for bzr log --authors. |
1427 |
self.wt = self.make_standard_commit('nicky', |
1428 |
authors=['John Doe <jdoe@example.com>', |
|
1429 |
'Jane Rey <jrey@example.com>']) |
|
1430 |
||
1431 |
def assertFormatterResult(self, formatter, who, result): |
|
1432 |
formatter_kwargs = dict() |
|
1433 |
if who is not None: |
|
4081.3.10
by Martin von Gagern
Renamed "authors" to "author_list_handler" in several places. |
1434 |
author_list_handler = log.author_list_registry.get(who) |
1435 |
formatter_kwargs['author_list_handler'] = author_list_handler |
|
4081.3.5
by Martin von Gagern
NEWS and test cases for bzr log --authors. |
1436 |
TestCaseForLogFormatter.assertFormatterResult(self, result, |
1437 |
self.wt.branch, formatter, formatter_kwargs=formatter_kwargs) |
|
1438 |
||
1439 |
def test_line_default(self): |
|
1440 |
self.assertFormatterResult(log.LineLogFormatter, None, """\ |
|
1441 |
1: John Doe 2005-11-22 add a
|
|
1442 |
""") |
|
1443 |
||
1444 |
def test_line_committer(self): |
|
1445 |
self.assertFormatterResult(log.LineLogFormatter, 'committer', """\ |
|
1446 |
1: Lorem Ipsum 2005-11-22 add a
|
|
1447 |
""") |
|
1448 |
||
1449 |
def test_line_first(self): |
|
1450 |
self.assertFormatterResult(log.LineLogFormatter, 'first', """\ |
|
1451 |
1: John Doe 2005-11-22 add a
|
|
1452 |
""") |
|
1453 |
||
1454 |
def test_line_all(self): |
|
1455 |
self.assertFormatterResult(log.LineLogFormatter, 'all', """\ |
|
1456 |
1: John Doe, Jane Rey 2005-11-22 add a
|
|
1457 |
""") |
|
1458 |
||
1459 |
||
1460 |
def test_short_default(self): |
|
1461 |
self.assertFormatterResult(log.ShortLogFormatter, None, """\ |
|
1462 |
1 John Doe\t2005-11-22 |
|
1463 |
add a
|
|
1464 |
||
1465 |
""") |
|
1466 |
||
1467 |
def test_short_committer(self): |
|
1468 |
self.assertFormatterResult(log.ShortLogFormatter, 'committer', """\ |
|
1469 |
1 Lorem Ipsum\t2005-11-22 |
|
1470 |
add a
|
|
1471 |
||
1472 |
""") |
|
1473 |
||
1474 |
def test_short_first(self): |
|
1475 |
self.assertFormatterResult(log.ShortLogFormatter, 'first', """\ |
|
1476 |
1 John Doe\t2005-11-22 |
|
1477 |
add a
|
|
1478 |
||
1479 |
""") |
|
1480 |
||
1481 |
def test_short_all(self): |
|
1482 |
self.assertFormatterResult(log.ShortLogFormatter, 'all', """\ |
|
1483 |
1 John Doe, Jane Rey\t2005-11-22 |
|
1484 |
add a
|
|
1485 |
||
1486 |
""") |
|
1487 |
||
1488 |
def test_long_default(self): |
|
1489 |
self.assertFormatterResult(log.LongLogFormatter, None, """\ |
|
1490 |
------------------------------------------------------------
|
|
1491 |
revno: 1
|
|
1492 |
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
|
|
1493 |
committer: Lorem Ipsum <test@example.com>
|
|
1494 |
branch nick: nicky
|
|
1495 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
|
1496 |
message:
|
|
1497 |
add a
|
|
1498 |
""") |
|
1499 |
||
1500 |
def test_long_committer(self): |
|
1501 |
self.assertFormatterResult(log.LongLogFormatter, 'committer', """\ |
|
1502 |
------------------------------------------------------------
|
|
1503 |
revno: 1
|
|
1504 |
committer: Lorem Ipsum <test@example.com>
|
|
1505 |
branch nick: nicky
|
|
1506 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
|
1507 |
message:
|
|
1508 |
add a
|
|
1509 |
""") |
|
1510 |
||
1511 |
def test_long_first(self): |
|
1512 |
self.assertFormatterResult(log.LongLogFormatter, 'first', """\ |
|
1513 |
------------------------------------------------------------
|
|
1514 |
revno: 1
|
|
1515 |
author: John Doe <jdoe@example.com>
|
|
1516 |
committer: Lorem Ipsum <test@example.com>
|
|
1517 |
branch nick: nicky
|
|
1518 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
|
1519 |
message:
|
|
1520 |
add a
|
|
1521 |
""") |
|
1522 |
||
1523 |
def test_long_all(self): |
|
1524 |
self.assertFormatterResult(log.LongLogFormatter, 'all', """\ |
|
1525 |
------------------------------------------------------------
|
|
1526 |
revno: 1
|
|
1527 |
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
|
|
1528 |
committer: Lorem Ipsum <test@example.com>
|
|
1529 |
branch nick: nicky
|
|
1530 |
timestamp: Tue 2005-11-22 00:00:00 +0000
|
|
1531 |
message:
|
|
1532 |
add a
|
|
1533 |
""") |
|
1534 |
||
1535 |
def test_gnu_changelog_default(self): |
|
1536 |
self.assertFormatterResult(log.GnuChangelogLogFormatter, None, """\ |
|
1537 |
2005-11-22 John Doe <jdoe@example.com>
|
|
1538 |
||
1539 |
\tadd a |
|
1540 |
||
1541 |
""") |
|
1542 |
||
1543 |
def test_gnu_changelog_committer(self): |
|
1544 |
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'committer', """\ |
|
1545 |
2005-11-22 Lorem Ipsum <test@example.com>
|
|
1546 |
||
1547 |
\tadd a |
|
1548 |
||
1549 |
""") |
|
1550 |
||
1551 |
def test_gnu_changelog_first(self): |
|
1552 |
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'first', """\ |
|
1553 |
2005-11-22 John Doe <jdoe@example.com>
|
|
1554 |
||
1555 |
\tadd a |
|
1556 |
||
1557 |
""") |
|
1558 |
||
1559 |
def test_gnu_changelog_all(self): |
|
1560 |
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'all', """\ |
|
1561 |
2005-11-22 John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
|
|
1562 |
||
1563 |
\tadd a |
|
1564 |
||
1565 |
""") |
|
4081.3.15
by Gary van der Merwe
Merge bzr.dev. |
1566 |
|
5691.1.3
by Jelmer Vernooij
Fix whitespace. |
1567 |
|
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1568 |
class TestLogExcludeAncestry(tests.TestCaseWithTransport): |
1569 |
||
1570 |
def make_branch_with_alternate_ancestries(self, relpath='.'): |
|
5155.1.5
by Vincent Ladeuil
Fixed as per Andrew's review. |
1571 |
# See test_merge_sorted_exclude_ancestry below for the difference with
|
1572 |
# bt.per_branch.test_iter_merge_sorted_revision.
|
|
6042.1.1
by Thomi Richards
Fix bug #747958 - 'levels' value is no longer overridden in Logger if the user explicitly asked for less details than the logger is capable of providing. |
1573 |
# TestIterMergeSortedRevisionsBushyGraph.
|
5155.1.5
by Vincent Ladeuil
Fixed as per Andrew's review. |
1574 |
# make_branch_with_alternate_ancestries
|
1575 |
# and test_merge_sorted_exclude_ancestry
|
|
1576 |
# See the FIXME in assertLogRevnos too.
|
|
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1577 |
builder = branchbuilder.BranchBuilder(self.get_transport(relpath)) |
1578 |
# 1
|
|
1579 |
# |\
|
|
5155.1.3
by Vincent Ladeuil
Fix the performance by finding the relevant subgraph once. |
1580 |
# 2 \
|
1581 |
# | |
|
|
1582 |
# | 1.1.1
|
|
1583 |
# | | \
|
|
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1584 |
# | | 1.2.1
|
1585 |
# | | /
|
|
1586 |
# | 1.1.2
|
|
1587 |
# | /
|
|
1588 |
# 3
|
|
1589 |
builder.start_series() |
|
1590 |
builder.build_snapshot('1', None, [ |
|
1591 |
('add', ('', 'TREE_ROOT', 'directory', '')),]) |
|
1592 |
builder.build_snapshot('1.1.1', ['1'], []) |
|
5155.1.3
by Vincent Ladeuil
Fix the performance by finding the relevant subgraph once. |
1593 |
builder.build_snapshot('2', ['1'], []) |
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1594 |
builder.build_snapshot('1.2.1', ['1.1.1'], []) |
1595 |
builder.build_snapshot('1.1.2', ['1.1.1', '1.2.1'], []) |
|
1596 |
builder.build_snapshot('3', ['2', '1.1.2'], []) |
|
1597 |
builder.finish_series() |
|
1598 |
br = builder.get_branch() |
|
1599 |
br.lock_read() |
|
1600 |
self.addCleanup(br.unlock) |
|
1601 |
return br |
|
1602 |
||
1603 |
def assertLogRevnos(self, expected_revnos, b, start, end, |
|
5268.4.2
by Vincent Ladeuil
Failing whitebox test for bug #575631. |
1604 |
exclude_common_ancestry, generate_merge_revisions=True): |
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1605 |
# FIXME: the layering in log makes it hard to test intermediate levels,
|
6376.1.1
by Vincent Ladeuil
Relax constraints on bzr log -rX..Y by falling back to the slower implementation when needed |
1606 |
# I wish adding filters with their parameters was easier...
|
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1607 |
# -- vila 20100413
|
1608 |
iter_revs = log._calc_view_revisions( |
|
1609 |
b, start, end, direction='reverse', |
|
5268.4.2
by Vincent Ladeuil
Failing whitebox test for bug #575631. |
1610 |
generate_merge_revisions=generate_merge_revisions, |
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1611 |
exclude_common_ancestry=exclude_common_ancestry) |
1612 |
self.assertEqual(expected_revnos, |
|
1613 |
[revid for revid, revno, depth in iter_revs]) |
|
1614 |
||
1615 |
def test_merge_sorted_exclude_ancestry(self): |
|
1616 |
b = self.make_branch_with_alternate_ancestries() |
|
5155.1.3
by Vincent Ladeuil
Fix the performance by finding the relevant subgraph once. |
1617 |
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'], |
5268.4.2
by Vincent Ladeuil
Failing whitebox test for bug #575631. |
1618 |
b, '1', '3', exclude_common_ancestry=False) |
5155.1.5
by Vincent Ladeuil
Fixed as per Andrew's review. |
1619 |
# '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
|
1620 |
# it should be mentioned even if merge_sort order will make it appear
|
|
1621 |
# after 1.1.1
|
|
5155.1.3
by Vincent Ladeuil
Fix the performance by finding the relevant subgraph once. |
1622 |
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'], |
5268.4.2
by Vincent Ladeuil
Failing whitebox test for bug #575631. |
1623 |
b, '1.1.1', '3', exclude_common_ancestry=True) |
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1624 |
|
5268.4.2
by Vincent Ladeuil
Failing whitebox test for bug #575631. |
1625 |
def test_merge_sorted_simple_revnos_exclude_ancestry(self): |
1626 |
b = self.make_branch_with_alternate_ancestries() |
|
1627 |
self.assertLogRevnos(['3', '2'], |
|
1628 |
b, '1', '3', exclude_common_ancestry=True, |
|
1629 |
generate_merge_revisions=False) |
|
5268.4.3
by Vincent Ladeuil
Respect --exclude-common-ancestry for linear ancestries. |
1630 |
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2'], |
1631 |
b, '1', '3', exclude_common_ancestry=True, |
|
1632 |
generate_merge_revisions=True) |
|
5097.1.12
by Vincent Ladeuil
Implement the --exclude-common-ancestry log option. |
1633 |
|
6042.1.1
by Thomi Richards
Fix bug #747958 - 'levels' value is no longer overridden in Logger if the user explicitly asked for less details than the logger is capable of providing. |
1634 |
|
1635 |
class TestLogDefaults(TestCaseForLogFormatter): |
|
1636 |
def test_default_log_level(self): |
|
6042.1.2
by Thomi Richards
Minor changes as a result of feedback from merge proposal. |
1637 |
"""
|
1638 |
Test to ensure that specifying 'levels=1' to make_log_request_dict
|
|
1639 |
doesn't get overwritten when using a LogFormatter that supports more
|
|
1640 |
detail.
|
|
1641 |
Fixes bug #747958.
|
|
1642 |
"""
|
|
6042.1.1
by Thomi Richards
Fix bug #747958 - 'levels' value is no longer overridden in Logger if the user explicitly asked for less details than the logger is capable of providing. |
1643 |
wt = self._prepare_tree_with_merges() |
1644 |
b = wt.branch |
|
1645 |
||
1646 |
class CustomLogFormatter(log.LogFormatter): |
|
1647 |
def __init__(self, *args, **kwargs): |
|
1648 |
super(CustomLogFormatter, self).__init__(*args, **kwargs) |
|
1649 |
self.revisions = [] |
|
1650 |
def get_levels(self): |
|
1651 |
# log formatter supports all levels:
|
|
1652 |
return 0 |
|
1653 |
def log_revision(self, revision): |
|
1654 |
self.revisions.append(revision) |
|
1655 |
||
1656 |
log_formatter = LogCatcher() |
|
1657 |
# First request we don't specify number of levels, we should get a
|
|
1658 |
# sensible default (whatever the LogFormatter handles - which in this
|
|
1659 |
# case is 0/everything):
|
|
1660 |
request = log.make_log_request_dict(limit=10) |
|
1661 |
log.Logger(b, request).show(log_formatter) |
|
1662 |
# should have all three revisions:
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1663 |
self.assertEqual(len(log_formatter.revisions), 3) |
6042.1.1
by Thomi Richards
Fix bug #747958 - 'levels' value is no longer overridden in Logger if the user explicitly asked for less details than the logger is capable of providing. |
1664 |
|
1665 |
del log_formatter |
|
1666 |
log_formatter = LogCatcher() |
|
1667 |
# now explicitly request mainline revisions only:
|
|
1668 |
request = log.make_log_request_dict(limit=10, levels=1) |
|
1669 |
log.Logger(b, request).show(log_formatter) |
|
1670 |
# should now only have 2 revisions:
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1671 |
self.assertEqual(len(log_formatter.revisions), 2) |
6283.1.13
by Jelmer Vernooij
ADd hpss call count tests for 'bzr log'. |
1672 |