bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2359.1.6
by John Arbash Meinel
Create a helper tree which has a semi-interesting history. |
1 |
# Copyright (C) 2005, 2006, 2007 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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
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 ( |
21 |
errors, |
|
22 |
log, |
|
23 |
registry, |
|
24 |
revision, |
|
25 |
revisionspec, |
|
26 |
tests, |
|
27 |
)
|
|
28 |
||
29 |
||
30 |
class TestCaseWithoutPropsHandler(tests.TestCaseWithTransport): |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
31 |
|
32 |
def setUp(self): |
|
33 |
super(TestCaseWithoutPropsHandler, self).setUp() |
|
34 |
# 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. |
35 |
self.properties_handler_registry = log.properties_handler_registry |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
36 |
# clean up the registry in log
|
37 |
log.properties_handler_registry = registry.Registry() |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
38 |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
39 |
def _cleanup(self): |
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
40 |
super(TestCaseWithoutPropsHandler, self)._cleanup() |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
41 |
# restore the custom properties handler registry
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
42 |
log.properties_handler_registry = self.properties_handler_registry |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
43 |
|
44 |
||
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
45 |
class LogCatcher(log.LogFormatter): |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
46 |
"""Pull log messages into list rather than displaying them. |
47 |
||
48 |
For ease of testing we save log messages here rather than actually
|
|
49 |
formatting them, so that we can precisely check the result without
|
|
50 |
being too dependent on the exact formatting.
|
|
51 |
||
52 |
We should also test the LogFormatter.
|
|
53 |
"""
|
|
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. |
54 |
|
2490.1.2
by John Arbash Meinel
Cleanup according to PEP8 and some other small whitespace fixes |
55 |
supports_delta = True |
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. |
56 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
57 |
def __init__(self): |
58 |
super(LogCatcher, self).__init__(to_file=None) |
|
59 |
self.logs = [] |
|
1704.2.20
by Martin Pool
log --line shows revision numbers (Alexander) |
60 |
|
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. |
61 |
def log_revision(self, revision): |
62 |
self.logs.append(revision) |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
63 |
|
64 |
||
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
65 |
class TestShowLog(tests.TestCaseWithTransport): |
1102
by Martin Pool
- merge test refactoring from robertc |
66 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
67 |
def checkDelta(self, delta, **kw): |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
68 |
"""Check the filenames touched by a delta are as expected. |
69 |
||
70 |
Caller only have to pass in the list of files for each part, all
|
|
71 |
unspecified parts are considered empty (and checked as such).
|
|
72 |
"""
|
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
73 |
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. |
74 |
# By default we expect an empty list
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
75 |
expected = kw.get(n, []) |
76 |
# strip out only the path components
|
|
77 |
got = [x[0] for x in getattr(delta, n)] |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
78 |
self.assertEqual(expected, got) |
79 |
||
80 |
def assertInvalidRevisonNumber(self, br, start, end): |
|
81 |
lf = LogCatcher() |
|
82 |
self.assertRaises(errors.InvalidRevisionNumber, |
|
83 |
log.show_log, br, lf, |
|
84 |
start_revision=start, end_revision=end) |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
85 |
|
974.1.54
by aaron.bentley at utoronto
Fixed the revno bug in log |
86 |
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. |
87 |
wt = self.make_branch_and_tree('.') |
88 |
b = wt.branch |
|
1092.3.4
by Robert Collins
update symlink branch to integration |
89 |
|
90 |
lf = LogCatcher() |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
91 |
wt.commit('empty commit') |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
92 |
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. |
93 |
|
94 |
# Since there is a single revision in the branch all the combinations
|
|
95 |
# below should fail.
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
96 |
self.assertInvalidRevisonNumber(b, 2, 1) |
97 |
self.assertInvalidRevisonNumber(b, 1, 2) |
|
98 |
self.assertInvalidRevisonNumber(b, 0, 2) |
|
99 |
self.assertInvalidRevisonNumber(b, 1, 0) |
|
100 |
self.assertInvalidRevisonNumber(b, -1, 1) |
|
101 |
self.assertInvalidRevisonNumber(b, 1, -1) |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
102 |
|
103 |
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. |
104 |
wt = self.make_branch_and_tree('.') |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
105 |
|
106 |
lf = LogCatcher() |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
107 |
log.show_log(wt.branch, lf) |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
108 |
# no entries yet
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
109 |
self.assertEqual([], lf.logs) |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
110 |
|
111 |
def test_empty_commit(self): |
|
112 |
wt = self.make_branch_and_tree('.') |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
113 |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
114 |
wt.commit('empty commit') |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
115 |
lf = LogCatcher() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
116 |
log.show_log(wt.branch, lf, verbose=True) |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
117 |
self.assertEqual(1, len(lf.logs)) |
118 |
self.assertEqual('1', lf.logs[0].revno) |
|
119 |
self.assertEqual('empty commit', lf.logs[0].rev.message) |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
120 |
self.checkDelta(lf.logs[0].delta) |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
121 |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
122 |
def test_simple_commit(self): |
123 |
wt = self.make_branch_and_tree('.') |
|
124 |
wt.commit('empty commit') |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
125 |
self.build_tree(['hello']) |
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
126 |
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. |
127 |
wt.commit('add one file', |
128 |
committer=u'\u013d\xf3r\xe9m \xcdp\u0161\xfam ' |
|
129 |
u'<test@example.com>') |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
130 |
lf = LogCatcher() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
131 |
log.show_log(wt.branch, lf, verbose=True) |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
132 |
self.assertEqual(2, len(lf.logs)) |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
133 |
# first one is most recent
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
134 |
log_entry = lf.logs[0] |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
135 |
self.assertEqual('2', log_entry.revno) |
136 |
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. |
137 |
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. |
138 |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
139 |
def test_commit_message_with_control_chars(self): |
140 |
wt = self.make_branch_and_tree('.') |
|
3831.1.6
by John Arbash Meinel
For the simple-log tests, avoid using '\r' in the test. |
141 |
msg = u"All 8-bit chars: " + ''.join([unichr(x) for x in range(256)]) |
142 |
msg = msg.replace(u'\r', u'\n') |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
143 |
wt.commit(msg) |
1185.11.5
by John Arbash Meinel
Merged up-to-date against mainline, still broken. |
144 |
lf = LogCatcher() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
145 |
log.show_log(wt.branch, lf, verbose=True) |
1185.11.5
by John Arbash Meinel
Merged up-to-date against mainline, still broken. |
146 |
committed_msg = lf.logs[0].rev.message |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
147 |
self.assertNotEqual(msg, committed_msg) |
148 |
self.assertTrue(len(committed_msg) > len(msg)) |
|
1393.4.2
by Harald Meland
Cleanup + better test of commit-msg control character escape code. |
149 |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
150 |
def test_commit_message_without_control_chars(self): |
151 |
wt = self.make_branch_and_tree('.') |
|
1393.4.2
by Harald Meland
Cleanup + better test of commit-msg control character escape code. |
152 |
# escaped. As ElementTree apparently does some kind of
|
153 |
# newline conversion, neither LF (\x0A) nor CR (\x0D) are
|
|
154 |
# included in the test commit message, even though they are
|
|
155 |
# valid XML 1.0 characters.
|
|
156 |
msg = "\x09" + ''.join([unichr(x) for x in range(0x20, 256)]) |
|
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
157 |
wt.commit(msg) |
1393.4.2
by Harald Meland
Cleanup + better test of commit-msg control character escape code. |
158 |
lf = LogCatcher() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
159 |
log.show_log(wt.branch, lf, verbose=True) |
1393.4.2
by Harald Meland
Cleanup + better test of commit-msg control character escape code. |
160 |
committed_msg = lf.logs[0].rev.message |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
161 |
self.assertEqual(msg, committed_msg) |
1185.31.22
by John Arbash Meinel
[merge] bzr.dev |
162 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
163 |
def test_deltas_in_merge_revisions(self): |
164 |
"""Check deltas created for both mainline and merge revisions""" |
|
165 |
wt = self.make_branch_and_tree('parent') |
|
166 |
self.build_tree(['parent/file1', 'parent/file2', 'parent/file3']) |
|
167 |
wt.add('file1') |
|
168 |
wt.add('file2') |
|
169 |
wt.commit(message='add file1 and file2') |
|
2581.1.6
by Martin Pool
fix up more run_bzr callers |
170 |
self.run_bzr('branch parent child') |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
171 |
os.unlink('child/file1') |
2911.6.1
by Blake Winton
Change 'print >> f,'s to 'f.write('s. |
172 |
file('child/file2', 'wb').write('hello\n') |
2581.1.6
by Martin Pool
fix up more run_bzr callers |
173 |
self.run_bzr(['commit', '-m', 'remove file1 and modify file2', |
174 |
'child']) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
175 |
os.chdir('parent') |
2581.1.6
by Martin Pool
fix up more run_bzr callers |
176 |
self.run_bzr('merge ../child') |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
177 |
wt.commit('merge child branch') |
178 |
os.chdir('..') |
|
179 |
b = wt.branch |
|
180 |
lf = LogCatcher() |
|
181 |
lf.supports_merge_revisions = True |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
182 |
log.show_log(b, lf, verbose=True) |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
183 |
|
184 |
self.assertEqual(3, len(lf.logs)) |
|
185 |
||
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
186 |
logentry = lf.logs[0] |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
187 |
self.assertEqual('2', logentry.revno) |
188 |
self.assertEqual('merge child branch', logentry.rev.message) |
|
189 |
self.checkDelta(logentry.delta, removed=['file1'], modified=['file2']) |
|
190 |
||
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
191 |
logentry = lf.logs[1] |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
192 |
self.assertEqual('1.1.1', logentry.revno) |
193 |
self.assertEqual('remove file1 and modify file2', logentry.rev.message) |
|
194 |
self.checkDelta(logentry.delta, removed=['file1'], modified=['file2']) |
|
195 |
||
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
196 |
logentry = lf.logs[2] |
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
197 |
self.assertEqual('1', logentry.revno) |
198 |
self.assertEqual('add file1 and file2', logentry.rev.message) |
|
199 |
self.checkDelta(logentry.delta, added=['file1', 'file2']) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
200 |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
201 |
def test_merges_nonsupporting_formatter(self): |
202 |
"""Tests that show_log will raise if the formatter doesn't |
|
203 |
support merge revisions."""
|
|
204 |
wt = self.make_branch_and_memory_tree('.') |
|
205 |
wt.lock_write() |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
206 |
self.addCleanup(wt.unlock) |
207 |
wt.add('') |
|
208 |
wt.commit('rev-1', rev_id='rev-1', |
|
209 |
timestamp=1132586655, timezone=36000, |
|
210 |
committer='Joe Foo <joe@foo.com>') |
|
211 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
212 |
timestamp=1132586700, timezone=36000, |
|
213 |
committer='Joe Foo <joe@foo.com>') |
|
214 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
215 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
216 |
wt.commit('rev-2', rev_id='rev-2b', |
|
217 |
timestamp=1132586800, timezone=36000, |
|
218 |
committer='Joe Foo <joe@foo.com>') |
|
219 |
logfile = self.make_utf8_encoded_stringio() |
|
220 |
formatter = log.ShortLogFormatter(to_file=logfile) |
|
221 |
wtb = wt.branch |
|
222 |
lf = LogCatcher() |
|
223 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
|
224 |
rev = revspec.in_history(wtb) |
|
225 |
self.assertRaises(errors.BzrCommandError, log.show_log, wtb, lf, |
|
3936.3.8
by Ian Clatworthy
back-out --strict |
226 |
start_revision=rev, end_revision=rev) |
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
227 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
228 |
|
229 |
def make_commits_with_trailing_newlines(wt): |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
230 |
"""Helper method for LogFormatter tests""" |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
231 |
b = wt.branch |
232 |
b.nick='test' |
|
233 |
open('a', 'wb').write('hello moto\n') |
|
234 |
wt.add('a') |
|
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. |
235 |
wt.commit('simple log message', rev_id='a1', |
236 |
timestamp=1132586655.459960938, timezone=-6*3600, |
|
237 |
committer='Joe Foo <joe@foo.com>') |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
238 |
open('b', 'wb').write('goodbye\n') |
239 |
wt.add('b') |
|
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. |
240 |
wt.commit('multiline\nlog\nmessage\n', rev_id='a2', |
241 |
timestamp=1132586842.411175966, timezone=-6*3600, |
|
242 |
committer='Joe Foo <joe@foo.com>', |
|
243 |
author='Joe Bar <joe@bar.com>') |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
244 |
|
245 |
open('c', 'wb').write('just another manic monday\n') |
|
246 |
wt.add('c') |
|
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. |
247 |
wt.commit('single line with trailing newline\n', rev_id='a3', |
248 |
timestamp=1132587176.835228920, timezone=-6*3600, |
|
249 |
committer = 'Joe Foo <joe@foo.com>') |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
250 |
return b |
251 |
||
252 |
||
2978.6.1
by Kent Gibson
Use normalize_log to more accurately test blackbox log output. |
253 |
def normalize_log(log): |
254 |
"""Replaces the variable lines of logs with fixed lines""" |
|
255 |
author = 'author: Dolor Sit <test@example.com>' |
|
256 |
committer = 'committer: Lorem Ipsum <test@example.com>' |
|
257 |
lines = log.splitlines(True) |
|
258 |
for idx,line in enumerate(lines): |
|
259 |
stripped_line = line.lstrip() |
|
260 |
indent = ' ' * (len(line) - len(stripped_line)) |
|
261 |
if stripped_line.startswith('author:'): |
|
262 |
lines[idx] = indent + author + '\n' |
|
263 |
elif stripped_line.startswith('committer:'): |
|
264 |
lines[idx] = indent + committer + '\n' |
|
265 |
elif stripped_line.startswith('timestamp:'): |
|
266 |
lines[idx] = indent + 'timestamp: Just now\n' |
|
267 |
return ''.join(lines) |
|
268 |
||
269 |
||
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
270 |
class TestShortLogFormatter(tests.TestCaseWithTransport): |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
271 |
|
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
272 |
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. |
273 |
wt = self.make_branch_and_tree('.') |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
274 |
b = make_commits_with_trailing_newlines(wt) |
2717.1.1
by Lukáš Lalinsky
Use UTF-8 encoded StringIO for log tests to avoid failures on non-ASCII committer names. |
275 |
sio = self.make_utf8_encoded_stringio() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
276 |
lf = log.ShortLogFormatter(to_file=sio) |
277 |
log.show_log(b, lf) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
278 |
self.assertEqualDiff("""\ |
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
279 |
3 Joe Foo\t2005-11-21 |
280 |
single line with trailing newline
|
|
281 |
||
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. |
282 |
2 Joe Bar\t2005-11-21 |
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
283 |
multiline
|
284 |
log
|
|
285 |
message
|
|
286 |
||
287 |
1 Joe Foo\t2005-11-21 |
|
288 |
simple log message
|
|
289 |
||
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
290 |
""", |
291 |
sio.getvalue()) |
|
1185.31.21
by John Arbash Meinel
Added test for log formatting, found bug when redirecting short logs to a file instead of stdout. |
292 |
|
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
293 |
def _prepare_tree_with_merges(self, with_tags=False): |
294 |
wt = self.make_branch_and_memory_tree('.') |
|
295 |
wt.lock_write() |
|
296 |
self.addCleanup(wt.unlock) |
|
297 |
wt.add('') |
|
298 |
wt.commit('rev-1', rev_id='rev-1', |
|
299 |
timestamp=1132586655, timezone=36000, |
|
300 |
committer='Joe Foo <joe@foo.com>') |
|
301 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
302 |
timestamp=1132586700, timezone=36000, |
|
303 |
committer='Joe Foo <joe@foo.com>') |
|
304 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
305 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
306 |
wt.commit('rev-2', rev_id='rev-2b', |
|
307 |
timestamp=1132586800, timezone=36000, |
|
308 |
committer='Joe Foo <joe@foo.com>') |
|
309 |
if with_tags: |
|
310 |
branch = wt.branch |
|
311 |
branch.tags.set_tag('v0.2', 'rev-2b') |
|
312 |
wt.commit('rev-3', rev_id='rev-3', |
|
313 |
timestamp=1132586900, timezone=36000, |
|
314 |
committer='Jane Foo <jane@foo.com>') |
|
315 |
branch.tags.set_tag('v1.0rc1', 'rev-3') |
|
316 |
branch.tags.set_tag('v1.0', 'rev-3') |
|
317 |
return wt |
|
318 |
||
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
319 |
def test_short_log_with_merges(self): |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
320 |
wt = self._prepare_tree_with_merges() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
321 |
logfile = self.make_utf8_encoded_stringio() |
322 |
formatter = log.ShortLogFormatter(to_file=logfile) |
|
323 |
log.show_log(wt.branch, formatter) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
324 |
self.assertEqualDiff("""\ |
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
325 |
2 Joe Foo\t2005-11-22 [merge] |
326 |
rev-2
|
|
327 |
||
328 |
1 Joe Foo\t2005-11-22 |
|
329 |
rev-1
|
|
330 |
||
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
331 |
""", |
332 |
logfile.getvalue()) |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
333 |
|
3943.4.2
by John Arbash Meinel
Add a test case which exercises this code path. |
334 |
def test_short_log_with_merges_and_range(self): |
335 |
wt = self.make_branch_and_memory_tree('.') |
|
336 |
wt.lock_write() |
|
337 |
self.addCleanup(wt.unlock) |
|
338 |
wt.add('') |
|
339 |
wt.commit('rev-1', rev_id='rev-1', |
|
340 |
timestamp=1132586655, timezone=36000, |
|
341 |
committer='Joe Foo <joe@foo.com>') |
|
342 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
343 |
timestamp=1132586700, timezone=36000, |
|
344 |
committer='Joe Foo <joe@foo.com>') |
|
345 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
346 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
347 |
wt.commit('rev-2b', rev_id='rev-2b', |
|
348 |
timestamp=1132586800, timezone=36000, |
|
349 |
committer='Joe Foo <joe@foo.com>') |
|
350 |
wt.commit('rev-3a', rev_id='rev-3a', |
|
351 |
timestamp=1132586800, timezone=36000, |
|
352 |
committer='Joe Foo <joe@foo.com>') |
|
353 |
wt.branch.set_last_revision_info(2, 'rev-2b') |
|
354 |
wt.set_parent_ids(['rev-2b', 'rev-3a']) |
|
355 |
wt.commit('rev-3b', rev_id='rev-3b', |
|
356 |
timestamp=1132586800, timezone=36000, |
|
357 |
committer='Joe Foo <joe@foo.com>') |
|
358 |
logfile = self.make_utf8_encoded_stringio() |
|
359 |
formatter = log.ShortLogFormatter(to_file=logfile) |
|
360 |
log.show_log(wt.branch, formatter, |
|
361 |
start_revision=2, end_revision=3) |
|
362 |
self.assertEqualDiff("""\ |
|
363 |
3 Joe Foo\t2005-11-22 [merge] |
|
364 |
rev-3b
|
|
365 |
||
366 |
2 Joe Foo\t2005-11-22 [merge] |
|
367 |
rev-2b
|
|
368 |
||
369 |
""", |
|
370 |
logfile.getvalue()) |
|
371 |
||
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
372 |
def test_short_log_with_tags(self): |
373 |
wt = self._prepare_tree_with_merges(with_tags=True) |
|
374 |
logfile = self.make_utf8_encoded_stringio() |
|
375 |
formatter = log.ShortLogFormatter(to_file=logfile) |
|
376 |
log.show_log(wt.branch, formatter) |
|
377 |
self.assertEqualDiff("""\ |
|
378 |
3 Jane Foo\t2005-11-22 {v1.0, v1.0rc1} |
|
379 |
rev-3
|
|
380 |
||
381 |
2 Joe Foo\t2005-11-22 {v0.2} [merge] |
|
382 |
rev-2
|
|
383 |
||
384 |
1 Joe Foo\t2005-11-22 |
|
385 |
rev-1
|
|
386 |
||
387 |
""", |
|
388 |
logfile.getvalue()) |
|
389 |
||
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
390 |
def test_short_log_single_merge_revision(self): |
391 |
wt = self.make_branch_and_memory_tree('.') |
|
392 |
wt.lock_write() |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
393 |
self.addCleanup(wt.unlock) |
394 |
wt.add('') |
|
395 |
wt.commit('rev-1', rev_id='rev-1', |
|
396 |
timestamp=1132586655, timezone=36000, |
|
397 |
committer='Joe Foo <joe@foo.com>') |
|
398 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
399 |
timestamp=1132586700, timezone=36000, |
|
400 |
committer='Joe Foo <joe@foo.com>') |
|
401 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
402 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
403 |
wt.commit('rev-2', rev_id='rev-2b', |
|
404 |
timestamp=1132586800, timezone=36000, |
|
405 |
committer='Joe Foo <joe@foo.com>') |
|
406 |
logfile = self.make_utf8_encoded_stringio() |
|
407 |
formatter = log.ShortLogFormatter(to_file=logfile) |
|
408 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
|
409 |
wtb = wt.branch |
|
410 |
rev = revspec.in_history(wtb) |
|
411 |
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
412 |
self.assertEqualDiff("""\ |
3947.1.10
by Ian Clatworthy
review feedback from vila |
413 |
1.1.1 Joe Foo\t2005-11-22 |
414 |
rev-merged
|
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
415 |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
416 |
""", |
417 |
logfile.getvalue()) |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
418 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
419 |
|
3947.1.2
by Ian Clatworthy
formatter tests |
420 |
class TestShortLogFormatterWithMergeRevisions(tests.TestCaseWithTransport): |
421 |
||
422 |
def test_short_merge_revs_log_with_merges(self): |
|
423 |
wt = self.make_branch_and_memory_tree('.') |
|
424 |
wt.lock_write() |
|
425 |
self.addCleanup(wt.unlock) |
|
426 |
wt.add('') |
|
427 |
wt.commit('rev-1', rev_id='rev-1', |
|
428 |
timestamp=1132586655, timezone=36000, |
|
429 |
committer='Joe Foo <joe@foo.com>') |
|
430 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
431 |
timestamp=1132586700, timezone=36000, |
|
432 |
committer='Joe Foo <joe@foo.com>') |
|
433 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
434 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
435 |
wt.commit('rev-2', rev_id='rev-2b', |
|
436 |
timestamp=1132586800, timezone=36000, |
|
437 |
committer='Joe Foo <joe@foo.com>') |
|
438 |
logfile = self.make_utf8_encoded_stringio() |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
439 |
formatter = log.ShortLogFormatter(to_file=logfile, levels=0) |
3947.1.2
by Ian Clatworthy
formatter tests |
440 |
log.show_log(wt.branch, formatter) |
3947.1.7
by Ian Clatworthy
tweak indenting/offsetting for --short given dotted revno lengths |
441 |
# Note that the 1.1.1 indenting is in fact correct given that
|
442 |
# the revision numbers are right justified within 5 characters
|
|
443 |
# for mainline revnos and 9 characters for dotted revnos.
|
|
3947.1.2
by Ian Clatworthy
formatter tests |
444 |
self.assertEqualDiff("""\ |
445 |
2 Joe Foo\t2005-11-22 [merge] |
|
446 |
rev-2
|
|
447 |
||
3947.1.10
by Ian Clatworthy
review feedback from vila |
448 |
1.1.1 Joe Foo\t2005-11-22 |
449 |
rev-merged
|
|
3947.1.2
by Ian Clatworthy
formatter tests |
450 |
|
451 |
1 Joe Foo\t2005-11-22 |
|
452 |
rev-1
|
|
453 |
||
454 |
""", |
|
455 |
logfile.getvalue()) |
|
456 |
||
457 |
def test_short_merge_revs_log_single_merge_revision(self): |
|
458 |
wt = self.make_branch_and_memory_tree('.') |
|
459 |
wt.lock_write() |
|
460 |
self.addCleanup(wt.unlock) |
|
461 |
wt.add('') |
|
462 |
wt.commit('rev-1', rev_id='rev-1', |
|
463 |
timestamp=1132586655, timezone=36000, |
|
464 |
committer='Joe Foo <joe@foo.com>') |
|
465 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
466 |
timestamp=1132586700, timezone=36000, |
|
467 |
committer='Joe Foo <joe@foo.com>') |
|
468 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
469 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
470 |
wt.commit('rev-2', rev_id='rev-2b', |
|
471 |
timestamp=1132586800, timezone=36000, |
|
472 |
committer='Joe Foo <joe@foo.com>') |
|
473 |
logfile = self.make_utf8_encoded_stringio() |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
474 |
formatter = log.ShortLogFormatter(to_file=logfile, levels=0) |
3947.1.2
by Ian Clatworthy
formatter tests |
475 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
476 |
wtb = wt.branch |
|
477 |
rev = revspec.in_history(wtb) |
|
478 |
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev) |
|
479 |
self.assertEqualDiff("""\ |
|
3947.1.10
by Ian Clatworthy
review feedback from vila |
480 |
1.1.1 Joe Foo\t2005-11-22 |
481 |
rev-merged
|
|
3947.1.2
by Ian Clatworthy
formatter tests |
482 |
|
483 |
""", |
|
484 |
logfile.getvalue()) |
|
485 |
||
486 |
||
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
487 |
class TestLongLogFormatter(TestCaseWithoutPropsHandler): |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
488 |
|
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
489 |
def test_verbose_log(self): |
490 |
"""Verbose log includes changed files |
|
491 |
|
|
492 |
bug #4676
|
|
493 |
"""
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
494 |
wt = self.make_branch_and_tree('.') |
495 |
b = wt.branch |
|
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
496 |
self.build_tree(['a']) |
1185.33.45
by Martin Pool
[merge] refactoring of branch vs working tree, etc (robertc) |
497 |
wt.add('a') |
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
498 |
# XXX: why does a longer nick show up?
|
499 |
b.nick = 'test_verbose_log' |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
500 |
wt.commit(message='add a', |
501 |
timestamp=1132711707, |
|
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
502 |
timezone=36000, |
503 |
committer='Lorem Ipsum <test@example.com>') |
|
504 |
logfile = file('out.tmp', 'w+') |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
505 |
formatter = log.LongLogFormatter(to_file=logfile) |
506 |
log.show_log(b, formatter, verbose=True) |
|
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
507 |
logfile.flush() |
508 |
logfile.seek(0) |
|
509 |
log_contents = logfile.read() |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
510 |
self.assertEqualDiff('''\ |
1185.33.41
by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676) |
511 |
------------------------------------------------------------
|
512 |
revno: 1
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
513 |
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) |
514 |
branch nick: test_verbose_log
|
515 |
timestamp: Wed 2005-11-23 12:08:27 +1000
|
|
516 |
message:
|
|
517 |
add a
|
|
518 |
added:
|
|
519 |
a
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
520 |
''', |
521 |
log_contents) |
|
1185.85.4
by John Arbash Meinel
currently broken, trying to fix things up. |
522 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
523 |
def test_merges_are_indented_by_level(self): |
524 |
wt = self.make_branch_and_tree('parent') |
|
525 |
wt.commit('first post') |
|
2581.1.6
by Martin Pool
fix up more run_bzr callers |
526 |
self.run_bzr('branch parent child') |
527 |
self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child']) |
|
528 |
self.run_bzr('branch child smallerchild') |
|
529 |
self.run_bzr(['commit', '-m', 'branch 2', '--unchanged', |
|
530 |
'smallerchild']) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
531 |
os.chdir('child') |
2581.1.6
by Martin Pool
fix up more run_bzr callers |
532 |
self.run_bzr('merge ../smallerchild') |
533 |
self.run_bzr(['commit', '-m', 'merge branch 2']) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
534 |
os.chdir('../parent') |
2581.1.6
by Martin Pool
fix up more run_bzr callers |
535 |
self.run_bzr('merge ../child') |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
536 |
wt.commit('merge branch 1') |
537 |
b = wt.branch |
|
2717.1.1
by Lukáš Lalinsky
Use UTF-8 encoded StringIO for log tests to avoid failures on non-ASCII committer names. |
538 |
sio = self.make_utf8_encoded_stringio() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
539 |
lf = log.LongLogFormatter(to_file=sio) |
540 |
log.show_log(b, lf, verbose=True) |
|
541 |
the_log = normalize_log(sio.getvalue()) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
542 |
self.assertEqualDiff("""\ |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
543 |
------------------------------------------------------------
|
544 |
revno: 2
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
545 |
committer: Lorem Ipsum <test@example.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
546 |
branch nick: parent
|
547 |
timestamp: Just now
|
|
548 |
message:
|
|
549 |
merge branch 1
|
|
550 |
------------------------------------------------------------
|
|
551 |
revno: 1.1.2
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
552 |
committer: Lorem Ipsum <test@example.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
553 |
branch nick: child
|
554 |
timestamp: Just now
|
|
555 |
message:
|
|
556 |
merge branch 2
|
|
557 |
------------------------------------------------------------
|
|
3170.3.4
by John Arbash Meinel
Update the tests for the new revision numbering. |
558 |
revno: 1.2.1
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
559 |
committer: Lorem Ipsum <test@example.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
560 |
branch nick: smallerchild
|
561 |
timestamp: Just now
|
|
562 |
message:
|
|
563 |
branch 2
|
|
564 |
------------------------------------------------------------
|
|
565 |
revno: 1.1.1
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
566 |
committer: Lorem Ipsum <test@example.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
567 |
branch nick: child
|
568 |
timestamp: Just now
|
|
569 |
message:
|
|
570 |
branch 1
|
|
571 |
------------------------------------------------------------
|
|
572 |
revno: 1
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
573 |
committer: Lorem Ipsum <test@example.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
574 |
branch nick: parent
|
575 |
timestamp: Just now
|
|
576 |
message:
|
|
577 |
first post
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
578 |
""", |
579 |
the_log) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
580 |
|
581 |
def test_verbose_merge_revisions_contain_deltas(self): |
|
582 |
wt = self.make_branch_and_tree('parent') |
|
583 |
self.build_tree(['parent/f1', 'parent/f2']) |
|
584 |
wt.add(['f1','f2']) |
|
585 |
wt.commit('first post') |
|
2581.1.6
by Martin Pool
fix up more run_bzr callers |
586 |
self.run_bzr('branch parent child') |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
587 |
os.unlink('child/f1') |
2911.6.1
by Blake Winton
Change 'print >> f,'s to 'f.write('s. |
588 |
file('child/f2', 'wb').write('hello\n') |
2581.1.6
by Martin Pool
fix up more run_bzr callers |
589 |
self.run_bzr(['commit', '-m', 'removed f1 and modified f2', |
590 |
'child']) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
591 |
os.chdir('parent') |
2581.1.6
by Martin Pool
fix up more run_bzr callers |
592 |
self.run_bzr('merge ../child') |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
593 |
wt.commit('merge branch 1') |
594 |
b = wt.branch |
|
2717.1.1
by Lukáš Lalinsky
Use UTF-8 encoded StringIO for log tests to avoid failures on non-ASCII committer names. |
595 |
sio = self.make_utf8_encoded_stringio() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
596 |
lf = log.LongLogFormatter(to_file=sio) |
597 |
log.show_log(b, lf, verbose=True) |
|
598 |
the_log = normalize_log(sio.getvalue()) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
599 |
self.assertEqualDiff("""\ |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
600 |
------------------------------------------------------------
|
601 |
revno: 2
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
602 |
committer: Lorem Ipsum <test@example.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
603 |
branch nick: parent
|
604 |
timestamp: Just now
|
|
605 |
message:
|
|
606 |
merge branch 1
|
|
607 |
removed:
|
|
608 |
f1
|
|
609 |
modified:
|
|
610 |
f2
|
|
611 |
------------------------------------------------------------
|
|
612 |
revno: 1.1.1
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
613 |
committer: Lorem Ipsum <test@example.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
614 |
branch nick: child
|
615 |
timestamp: Just now
|
|
616 |
message:
|
|
617 |
removed f1 and modified f2
|
|
618 |
removed:
|
|
619 |
f1
|
|
620 |
modified:
|
|
621 |
f2
|
|
622 |
------------------------------------------------------------
|
|
623 |
revno: 1
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
624 |
committer: Lorem Ipsum <test@example.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
625 |
branch nick: parent
|
626 |
timestamp: Just now
|
|
627 |
message:
|
|
628 |
first post
|
|
629 |
added:
|
|
630 |
f1
|
|
631 |
f2
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
632 |
""", |
633 |
the_log) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
634 |
|
635 |
def test_trailing_newlines(self): |
|
636 |
wt = self.make_branch_and_tree('.') |
|
637 |
b = make_commits_with_trailing_newlines(wt) |
|
2717.1.1
by Lukáš Lalinsky
Use UTF-8 encoded StringIO for log tests to avoid failures on non-ASCII committer names. |
638 |
sio = self.make_utf8_encoded_stringio() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
639 |
lf = log.LongLogFormatter(to_file=sio) |
640 |
log.show_log(b, lf) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
641 |
self.assertEqualDiff("""\ |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
642 |
------------------------------------------------------------
|
643 |
revno: 3
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
644 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
645 |
branch nick: test
|
646 |
timestamp: Mon 2005-11-21 09:32:56 -0600
|
|
647 |
message:
|
|
648 |
single line with trailing newline
|
|
649 |
------------------------------------------------------------
|
|
650 |
revno: 2
|
|
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. |
651 |
author: Joe Bar <joe@bar.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
652 |
committer: Joe Foo <joe@foo.com>
|
653 |
branch nick: test
|
|
654 |
timestamp: Mon 2005-11-21 09:27:22 -0600
|
|
655 |
message:
|
|
656 |
multiline
|
|
657 |
log
|
|
658 |
message
|
|
659 |
------------------------------------------------------------
|
|
660 |
revno: 1
|
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
661 |
committer: Joe Foo <joe@foo.com>
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
662 |
branch nick: test
|
663 |
timestamp: Mon 2005-11-21 09:24:15 -0600
|
|
664 |
message:
|
|
665 |
simple log message
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
666 |
""", |
667 |
sio.getvalue()) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
668 |
|
2671.5.7
by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer. |
669 |
def test_author_in_log(self): |
670 |
"""Log includes the author name if it's set in |
|
671 |
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. |
672 |
"""
|
673 |
wt = self.make_branch_and_tree('.') |
|
674 |
b = wt.branch |
|
675 |
self.build_tree(['a']) |
|
676 |
wt.add('a') |
|
677 |
b.nick = 'test_author_log' |
|
678 |
wt.commit(message='add a', |
|
679 |
timestamp=1132711707, |
|
680 |
timezone=36000, |
|
681 |
committer='Lorem Ipsum <test@example.com>', |
|
2671.2.5
by Lukáš Lalinský
Fixes for comments from the mailing list. |
682 |
author='John Doe <jdoe@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. |
683 |
sio = StringIO() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
684 |
formatter = log.LongLogFormatter(to_file=sio) |
685 |
log.show_log(b, formatter) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
686 |
self.assertEqualDiff('''\ |
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. |
687 |
------------------------------------------------------------
|
688 |
revno: 1
|
|
689 |
author: John Doe <jdoe@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. |
690 |
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. |
691 |
branch nick: test_author_log
|
692 |
timestamp: Wed 2005-11-23 12:08:27 +1000
|
|
693 |
message:
|
|
694 |
add a
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
695 |
''', |
696 |
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. |
697 |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
698 |
def test_properties_in_log(self): |
699 |
"""Log includes the custom properties returned by the registered |
|
700 |
handlers.
|
|
701 |
"""
|
|
702 |
wt = self.make_branch_and_tree('.') |
|
703 |
b = wt.branch |
|
704 |
self.build_tree(['a']) |
|
705 |
wt.add('a') |
|
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
706 |
b.nick = 'test_properties_in_log' |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
707 |
wt.commit(message='add a', |
708 |
timestamp=1132711707, |
|
709 |
timezone=36000, |
|
710 |
committer='Lorem Ipsum <test@example.com>', |
|
711 |
author='John Doe <jdoe@example.com>') |
|
712 |
sio = StringIO() |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
713 |
formatter = log.LongLogFormatter(to_file=sio) |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
714 |
try: |
715 |
def trivial_custom_prop_handler(revision): |
|
716 |
return {'test_prop':'test_value'} |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
717 |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
718 |
log.properties_handler_registry.register( |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
719 |
'trivial_custom_prop_handler', |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
720 |
trivial_custom_prop_handler) |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
721 |
log.show_log(b, formatter) |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
722 |
finally: |
723 |
log.properties_handler_registry.remove( |
|
724 |
'trivial_custom_prop_handler') |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
725 |
self.assertEqualDiff('''\ |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
726 |
------------------------------------------------------------
|
727 |
revno: 1
|
|
728 |
test_prop: test_value
|
|
729 |
author: John Doe <jdoe@example.com>
|
|
730 |
committer: Lorem Ipsum <test@example.com>
|
|
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
731 |
branch nick: test_properties_in_log
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
732 |
timestamp: Wed 2005-11-23 12:08:27 +1000
|
733 |
message:
|
|
734 |
add a
|
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
735 |
''', |
736 |
sio.getvalue()) |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
737 |
|
3976.3.1
by Neil Martinsen-Burrell
Add custom properties handling to short log format |
738 |
def test_properties_in_short_log(self): |
739 |
"""Log includes the custom properties returned by the registered |
|
740 |
handlers.
|
|
741 |
"""
|
|
742 |
wt = self.make_branch_and_tree('.') |
|
743 |
b = wt.branch |
|
744 |
self.build_tree(['a']) |
|
745 |
wt.add('a') |
|
746 |
b.nick = 'test_properties_in_short_log' |
|
747 |
wt.commit(message='add a', |
|
748 |
timestamp=1132711707, |
|
749 |
timezone=36000, |
|
750 |
committer='Lorem Ipsum <test@example.com>', |
|
751 |
author='John Doe <jdoe@example.com>') |
|
752 |
sio = StringIO() |
|
753 |
formatter = log.ShortLogFormatter(to_file=sio) |
|
754 |
try: |
|
755 |
def trivial_custom_prop_handler(revision): |
|
756 |
return {'test_prop':'test_value'} |
|
757 |
||
758 |
log.properties_handler_registry.register( |
|
759 |
'trivial_custom_prop_handler', |
|
760 |
trivial_custom_prop_handler) |
|
761 |
log.show_log(b, formatter) |
|
762 |
finally: |
|
763 |
log.properties_handler_registry.remove( |
|
764 |
'trivial_custom_prop_handler') |
|
765 |
self.assertEqualDiff('''\ |
|
3976.3.3
by Jelmer Vernooij
remove a tab character. |
766 |
1 John Doe\t2005-11-23 |
3976.3.1
by Neil Martinsen-Burrell
Add custom properties handling to short log format |
767 |
test_prop: test_value
|
768 |
add a
|
|
769 |
||
770 |
''', |
|
771 |
sio.getvalue()) |
|
772 |
||
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
773 |
def test_error_in_properties_handler(self): |
774 |
"""Log includes the custom properties returned by the registered |
|
775 |
handlers.
|
|
776 |
"""
|
|
777 |
wt = self.make_branch_and_tree('.') |
|
778 |
b = wt.branch |
|
779 |
self.build_tree(['a']) |
|
780 |
wt.add('a') |
|
781 |
b.nick = 'test_author_log' |
|
782 |
wt.commit(message='add a', |
|
783 |
timestamp=1132711707, |
|
784 |
timezone=36000, |
|
785 |
committer='Lorem Ipsum <test@example.com>', |
|
786 |
author='John Doe <jdoe@example.com>', |
|
787 |
revprops={'first_prop':'first_value'}) |
|
788 |
sio = StringIO() |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
789 |
formatter = log.LongLogFormatter(to_file=sio) |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
790 |
try: |
791 |
def trivial_custom_prop_handler(revision): |
|
792 |
raise StandardError("a test error") |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
793 |
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
794 |
log.properties_handler_registry.register( |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
795 |
'trivial_custom_prop_handler', |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
796 |
trivial_custom_prop_handler) |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
797 |
self.assertRaises(StandardError, log.show_log, b, formatter,) |
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
798 |
finally: |
799 |
log.properties_handler_registry.remove( |
|
800 |
'trivial_custom_prop_handler') |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
801 |
|
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
802 |
def test_properties_handler_bad_argument(self): |
803 |
wt = self.make_branch_and_tree('.') |
|
804 |
b = wt.branch |
|
805 |
self.build_tree(['a']) |
|
806 |
wt.add('a') |
|
807 |
b.nick = 'test_author_log' |
|
808 |
wt.commit(message='add a', |
|
809 |
timestamp=1132711707, |
|
810 |
timezone=36000, |
|
811 |
committer='Lorem Ipsum <test@example.com>', |
|
812 |
author='John Doe <jdoe@example.com>', |
|
813 |
revprops={'a_prop':'test_value'}) |
|
814 |
sio = StringIO() |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
815 |
formatter = log.LongLogFormatter(to_file=sio) |
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
816 |
try: |
817 |
def bad_argument_prop_handler(revision): |
|
818 |
return {'custom_prop_name':revision.properties['a_prop']} |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
819 |
|
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
820 |
log.properties_handler_registry.register( |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
821 |
'bad_argument_prop_handler', |
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
822 |
bad_argument_prop_handler) |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
823 |
|
824 |
self.assertRaises(AttributeError, formatter.show_properties, |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
825 |
'a revision', '') |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
826 |
|
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
827 |
revision = b.repository.get_revision(b.last_revision()) |
828 |
formatter.show_properties(revision, '') |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
829 |
self.assertEqualDiff('''custom_prop_name: test_value\n''', |
830 |
sio.getvalue()) |
|
3144.7.13
by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring |
831 |
finally: |
832 |
log.properties_handler_registry.remove( |
|
833 |
'bad_argument_prop_handler') |
|
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. |
834 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
835 |
|
3947.1.2
by Ian Clatworthy
formatter tests |
836 |
class TestLongLogFormatterWithoutMergeRevisions(TestCaseWithoutPropsHandler): |
837 |
||
838 |
def test_long_verbose_log(self): |
|
839 |
"""Verbose log includes changed files |
|
840 |
|
|
841 |
bug #4676
|
|
842 |
"""
|
|
843 |
wt = self.make_branch_and_tree('.') |
|
844 |
b = wt.branch |
|
845 |
self.build_tree(['a']) |
|
846 |
wt.add('a') |
|
847 |
# XXX: why does a longer nick show up?
|
|
848 |
b.nick = 'test_verbose_log' |
|
849 |
wt.commit(message='add a', |
|
850 |
timestamp=1132711707, |
|
851 |
timezone=36000, |
|
852 |
committer='Lorem Ipsum <test@example.com>') |
|
853 |
logfile = file('out.tmp', 'w+') |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
854 |
formatter = log.LongLogFormatter(to_file=logfile, levels=1) |
3947.1.2
by Ian Clatworthy
formatter tests |
855 |
log.show_log(b, formatter, verbose=True) |
856 |
logfile.flush() |
|
857 |
logfile.seek(0) |
|
858 |
log_contents = logfile.read() |
|
859 |
self.assertEqualDiff('''\ |
|
860 |
------------------------------------------------------------
|
|
861 |
revno: 1
|
|
862 |
committer: Lorem Ipsum <test@example.com>
|
|
863 |
branch nick: test_verbose_log
|
|
864 |
timestamp: Wed 2005-11-23 12:08:27 +1000
|
|
865 |
message:
|
|
866 |
add a
|
|
867 |
added:
|
|
868 |
a
|
|
869 |
''', |
|
870 |
log_contents) |
|
871 |
||
872 |
def test_long_verbose_contain_deltas(self): |
|
873 |
wt = self.make_branch_and_tree('parent') |
|
874 |
self.build_tree(['parent/f1', 'parent/f2']) |
|
875 |
wt.add(['f1','f2']) |
|
876 |
wt.commit('first post') |
|
877 |
self.run_bzr('branch parent child') |
|
878 |
os.unlink('child/f1') |
|
879 |
file('child/f2', 'wb').write('hello\n') |
|
880 |
self.run_bzr(['commit', '-m', 'removed f1 and modified f2', |
|
881 |
'child']) |
|
882 |
os.chdir('parent') |
|
883 |
self.run_bzr('merge ../child') |
|
884 |
wt.commit('merge branch 1') |
|
885 |
b = wt.branch |
|
886 |
sio = self.make_utf8_encoded_stringio() |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
887 |
lf = log.LongLogFormatter(to_file=sio, levels=1) |
3947.1.2
by Ian Clatworthy
formatter tests |
888 |
log.show_log(b, lf, verbose=True) |
889 |
the_log = normalize_log(sio.getvalue()) |
|
890 |
self.assertEqualDiff("""\ |
|
891 |
------------------------------------------------------------
|
|
892 |
revno: 2
|
|
893 |
committer: Lorem Ipsum <test@example.com>
|
|
894 |
branch nick: parent
|
|
895 |
timestamp: Just now
|
|
896 |
message:
|
|
897 |
merge branch 1
|
|
898 |
removed:
|
|
899 |
f1
|
|
900 |
modified:
|
|
901 |
f2
|
|
902 |
------------------------------------------------------------
|
|
903 |
revno: 1
|
|
904 |
committer: Lorem Ipsum <test@example.com>
|
|
905 |
branch nick: parent
|
|
906 |
timestamp: Just now
|
|
907 |
message:
|
|
908 |
first post
|
|
909 |
added:
|
|
910 |
f1
|
|
911 |
f2
|
|
912 |
""", |
|
913 |
the_log) |
|
914 |
||
915 |
def test_long_trailing_newlines(self): |
|
916 |
wt = self.make_branch_and_tree('.') |
|
917 |
b = make_commits_with_trailing_newlines(wt) |
|
918 |
sio = self.make_utf8_encoded_stringio() |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
919 |
lf = log.LongLogFormatter(to_file=sio, levels=1) |
3947.1.2
by Ian Clatworthy
formatter tests |
920 |
log.show_log(b, lf) |
921 |
self.assertEqualDiff("""\ |
|
922 |
------------------------------------------------------------
|
|
923 |
revno: 3
|
|
924 |
committer: Joe Foo <joe@foo.com>
|
|
925 |
branch nick: test
|
|
926 |
timestamp: Mon 2005-11-21 09:32:56 -0600
|
|
927 |
message:
|
|
928 |
single line with trailing newline
|
|
929 |
------------------------------------------------------------
|
|
930 |
revno: 2
|
|
931 |
author: Joe Bar <joe@bar.com>
|
|
932 |
committer: Joe Foo <joe@foo.com>
|
|
933 |
branch nick: test
|
|
934 |
timestamp: Mon 2005-11-21 09:27:22 -0600
|
|
935 |
message:
|
|
936 |
multiline
|
|
937 |
log
|
|
938 |
message
|
|
939 |
------------------------------------------------------------
|
|
940 |
revno: 1
|
|
941 |
committer: Joe Foo <joe@foo.com>
|
|
942 |
branch nick: test
|
|
943 |
timestamp: Mon 2005-11-21 09:24:15 -0600
|
|
944 |
message:
|
|
945 |
simple log message
|
|
946 |
""", |
|
947 |
sio.getvalue()) |
|
948 |
||
949 |
def test_long_author_in_log(self): |
|
950 |
"""Log includes the author name if it's set in |
|
951 |
the revision properties
|
|
952 |
"""
|
|
953 |
wt = self.make_branch_and_tree('.') |
|
954 |
b = wt.branch |
|
955 |
self.build_tree(['a']) |
|
956 |
wt.add('a') |
|
957 |
b.nick = 'test_author_log' |
|
958 |
wt.commit(message='add a', |
|
959 |
timestamp=1132711707, |
|
960 |
timezone=36000, |
|
961 |
committer='Lorem Ipsum <test@example.com>', |
|
962 |
author='John Doe <jdoe@example.com>') |
|
963 |
sio = StringIO() |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
964 |
formatter = log.LongLogFormatter(to_file=sio, levels=1) |
3947.1.2
by Ian Clatworthy
formatter tests |
965 |
log.show_log(b, formatter) |
966 |
self.assertEqualDiff('''\ |
|
967 |
------------------------------------------------------------
|
|
968 |
revno: 1
|
|
969 |
author: John Doe <jdoe@example.com>
|
|
970 |
committer: Lorem Ipsum <test@example.com>
|
|
971 |
branch nick: test_author_log
|
|
972 |
timestamp: Wed 2005-11-23 12:08:27 +1000
|
|
973 |
message:
|
|
974 |
add a
|
|
975 |
''', |
|
976 |
sio.getvalue()) |
|
977 |
||
978 |
def test_long_properties_in_log(self): |
|
979 |
"""Log includes the custom properties returned by the registered |
|
980 |
handlers.
|
|
981 |
"""
|
|
982 |
wt = self.make_branch_and_tree('.') |
|
983 |
b = wt.branch |
|
984 |
self.build_tree(['a']) |
|
985 |
wt.add('a') |
|
986 |
b.nick = 'test_properties_in_log' |
|
987 |
wt.commit(message='add a', |
|
988 |
timestamp=1132711707, |
|
989 |
timezone=36000, |
|
990 |
committer='Lorem Ipsum <test@example.com>', |
|
991 |
author='John Doe <jdoe@example.com>') |
|
992 |
sio = StringIO() |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
993 |
formatter = log.LongLogFormatter(to_file=sio, levels=1) |
3947.1.2
by Ian Clatworthy
formatter tests |
994 |
try: |
995 |
def trivial_custom_prop_handler(revision): |
|
996 |
return {'test_prop':'test_value'} |
|
997 |
||
998 |
log.properties_handler_registry.register( |
|
999 |
'trivial_custom_prop_handler', |
|
1000 |
trivial_custom_prop_handler) |
|
1001 |
log.show_log(b, formatter) |
|
1002 |
finally: |
|
1003 |
log.properties_handler_registry.remove( |
|
1004 |
'trivial_custom_prop_handler') |
|
1005 |
self.assertEqualDiff('''\ |
|
1006 |
------------------------------------------------------------
|
|
1007 |
revno: 1
|
|
1008 |
test_prop: test_value
|
|
1009 |
author: John Doe <jdoe@example.com>
|
|
1010 |
committer: Lorem Ipsum <test@example.com>
|
|
1011 |
branch nick: test_properties_in_log
|
|
1012 |
timestamp: Wed 2005-11-23 12:08:27 +1000
|
|
1013 |
message:
|
|
1014 |
add a
|
|
1015 |
''', |
|
1016 |
sio.getvalue()) |
|
1017 |
||
1018 |
||
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1019 |
class TestLineLogFormatter(tests.TestCaseWithTransport): |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
1020 |
|
1704.2.20
by Martin Pool
log --line shows revision numbers (Alexander) |
1021 |
def test_line_log(self): |
1022 |
"""Line log should show revno |
|
1023 |
|
|
1024 |
bug #5162
|
|
1025 |
"""
|
|
1026 |
wt = self.make_branch_and_tree('.') |
|
1027 |
b = wt.branch |
|
1028 |
self.build_tree(['a']) |
|
1029 |
wt.add('a') |
|
1030 |
b.nick = 'test-line-log' |
|
3642.1.5
by Robert Collins
Separate out batching of revisions. |
1031 |
wt.commit(message='add a', |
1032 |
timestamp=1132711707, |
|
1704.2.20
by Martin Pool
log --line shows revision numbers (Alexander) |
1033 |
timezone=36000, |
1034 |
committer='Line-Log-Formatter Tester <test@line.log>') |
|
1035 |
logfile = file('out.tmp', 'w+') |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1036 |
formatter = log.LineLogFormatter(to_file=logfile) |
1037 |
log.show_log(b, formatter) |
|
1704.2.20
by Martin Pool
log --line shows revision numbers (Alexander) |
1038 |
logfile.flush() |
1039 |
logfile.seek(0) |
|
1040 |
log_contents = logfile.read() |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
1041 |
self.assertEqualDiff('1: Line-Log-Formatte... 2005-11-23 add a\n', |
1042 |
log_contents) |
|
1756.2.20
by Aaron Bentley
Optimize log formats that don't show merges |
1043 |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
1044 |
def test_trailing_newlines(self): |
1045 |
wt = self.make_branch_and_tree('.') |
|
1046 |
b = make_commits_with_trailing_newlines(wt) |
|
2717.1.1
by Lukáš Lalinsky
Use UTF-8 encoded StringIO for log tests to avoid failures on non-ASCII committer names. |
1047 |
sio = self.make_utf8_encoded_stringio() |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1048 |
lf = log.LineLogFormatter(to_file=sio) |
1049 |
log.show_log(b, lf) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
1050 |
self.assertEqualDiff("""\ |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
1051 |
3: Joe Foo 2005-11-21 single line with trailing newline
|
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. |
1052 |
2: Joe Bar 2005-11-21 multiline
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
1053 |
1: Joe Foo 2005-11-21 simple log message
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
1054 |
""", |
1055 |
sio.getvalue()) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
1056 |
|
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
1057 |
def _prepare_tree_with_merges(self, with_tags=False): |
1058 |
wt = self.make_branch_and_memory_tree('.') |
|
1059 |
wt.lock_write() |
|
1060 |
self.addCleanup(wt.unlock) |
|
1061 |
wt.add('') |
|
1062 |
wt.commit('rev-1', rev_id='rev-1', |
|
1063 |
timestamp=1132586655, timezone=36000, |
|
1064 |
committer='Joe Foo <joe@foo.com>') |
|
1065 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
1066 |
timestamp=1132586700, timezone=36000, |
|
1067 |
committer='Joe Foo <joe@foo.com>') |
|
1068 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
1069 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
1070 |
wt.commit('rev-2', rev_id='rev-2b', |
|
1071 |
timestamp=1132586800, timezone=36000, |
|
1072 |
committer='Joe Foo <joe@foo.com>') |
|
1073 |
if with_tags: |
|
1074 |
branch = wt.branch |
|
1075 |
branch.tags.set_tag('v0.2', 'rev-2b') |
|
1076 |
wt.commit('rev-3', rev_id='rev-3', |
|
1077 |
timestamp=1132586900, timezone=36000, |
|
1078 |
committer='Jane Foo <jane@foo.com>') |
|
1079 |
branch.tags.set_tag('v1.0rc1', 'rev-3') |
|
1080 |
branch.tags.set_tag('v1.0', 'rev-3') |
|
1081 |
return wt |
|
1082 |
||
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
1083 |
def test_line_log_single_merge_revision(self): |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
1084 |
wt = self._prepare_tree_with_merges() |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1085 |
logfile = self.make_utf8_encoded_stringio() |
1086 |
formatter = log.LineLogFormatter(to_file=logfile) |
|
1087 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
|
1088 |
wtb = wt.branch |
|
1089 |
rev = revspec.in_history(wtb) |
|
1090 |
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
1091 |
self.assertEqualDiff("""\ |
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
1092 |
1.1.1: Joe Foo 2005-11-22 rev-merged
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
1093 |
""", |
1094 |
logfile.getvalue()) |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
1095 |
|
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
1096 |
def test_line_log_with_tags(self): |
1097 |
wt = self._prepare_tree_with_merges(with_tags=True) |
|
1098 |
logfile = self.make_utf8_encoded_stringio() |
|
1099 |
formatter = log.LineLogFormatter(to_file=logfile) |
|
1100 |
log.show_log(wt.branch, formatter) |
|
1101 |
self.assertEqualDiff("""\ |
|
3946.3.3
by Ian Clatworthy
feedback from jelmer re position of tags in --line |
1102 |
3: Jane Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
|
3983.2.1
by Neil Martinsen-Burrell
add merge indication to the line format |
1103 |
2: Joe Foo 2005-11-22 [merge] {v0.2} rev-2 |
3946.3.2
by Ian Clatworthy
add tests & NEWS item |
1104 |
1: Joe Foo 2005-11-22 rev-1
|
1105 |
""", |
|
1106 |
logfile.getvalue()) |
|
2997.1.1
by Kent Gibson
Support logging single merge revisions with short and line log formatters. |
1107 |
|
3947.1.2
by Ian Clatworthy
formatter tests |
1108 |
class TestLineLogFormatterWithMergeRevisions(tests.TestCaseWithTransport): |
1109 |
||
1110 |
def test_line_merge_revs_log(self): |
|
1111 |
"""Line log should show revno |
|
1112 |
|
|
1113 |
bug #5162
|
|
1114 |
"""
|
|
1115 |
wt = self.make_branch_and_tree('.') |
|
1116 |
b = wt.branch |
|
1117 |
self.build_tree(['a']) |
|
1118 |
wt.add('a') |
|
1119 |
b.nick = 'test-line-log' |
|
1120 |
wt.commit(message='add a', |
|
1121 |
timestamp=1132711707, |
|
1122 |
timezone=36000, |
|
1123 |
committer='Line-Log-Formatter Tester <test@line.log>') |
|
1124 |
logfile = file('out.tmp', 'w+') |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
1125 |
formatter = log.LineLogFormatter(to_file=logfile, levels=0) |
3947.1.2
by Ian Clatworthy
formatter tests |
1126 |
log.show_log(b, formatter) |
1127 |
logfile.flush() |
|
1128 |
logfile.seek(0) |
|
1129 |
log_contents = logfile.read() |
|
1130 |
self.assertEqualDiff('1: Line-Log-Formatte... 2005-11-23 add a\n', |
|
1131 |
log_contents) |
|
1132 |
||
1133 |
def test_line_merge_revs_log_single_merge_revision(self): |
|
1134 |
wt = self.make_branch_and_memory_tree('.') |
|
1135 |
wt.lock_write() |
|
1136 |
self.addCleanup(wt.unlock) |
|
1137 |
wt.add('') |
|
1138 |
wt.commit('rev-1', rev_id='rev-1', |
|
1139 |
timestamp=1132586655, timezone=36000, |
|
1140 |
committer='Joe Foo <joe@foo.com>') |
|
1141 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
1142 |
timestamp=1132586700, timezone=36000, |
|
1143 |
committer='Joe Foo <joe@foo.com>') |
|
1144 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
1145 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
1146 |
wt.commit('rev-2', rev_id='rev-2b', |
|
1147 |
timestamp=1132586800, timezone=36000, |
|
1148 |
committer='Joe Foo <joe@foo.com>') |
|
1149 |
logfile = self.make_utf8_encoded_stringio() |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
1150 |
formatter = log.LineLogFormatter(to_file=logfile, levels=0) |
3947.1.2
by Ian Clatworthy
formatter tests |
1151 |
revspec = revisionspec.RevisionSpec.from_string('1.1.1') |
1152 |
wtb = wt.branch |
|
1153 |
rev = revspec.in_history(wtb) |
|
1154 |
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev) |
|
1155 |
self.assertEqualDiff("""\ |
|
1156 |
1.1.1: Joe Foo 2005-11-22 rev-merged
|
|
1157 |
""", |
|
1158 |
logfile.getvalue()) |
|
1159 |
||
1160 |
def test_line_merge_revs_log_with_merges(self): |
|
1161 |
wt = self.make_branch_and_memory_tree('.') |
|
1162 |
wt.lock_write() |
|
1163 |
self.addCleanup(wt.unlock) |
|
1164 |
wt.add('') |
|
1165 |
wt.commit('rev-1', rev_id='rev-1', |
|
1166 |
timestamp=1132586655, timezone=36000, |
|
1167 |
committer='Joe Foo <joe@foo.com>') |
|
1168 |
wt.commit('rev-merged', rev_id='rev-2a', |
|
1169 |
timestamp=1132586700, timezone=36000, |
|
1170 |
committer='Joe Foo <joe@foo.com>') |
|
1171 |
wt.set_parent_ids(['rev-1', 'rev-2a']) |
|
1172 |
wt.branch.set_last_revision_info(1, 'rev-1') |
|
1173 |
wt.commit('rev-2', rev_id='rev-2b', |
|
1174 |
timestamp=1132586800, timezone=36000, |
|
1175 |
committer='Joe Foo <joe@foo.com>') |
|
1176 |
logfile = self.make_utf8_encoded_stringio() |
|
3947.1.6
by Ian Clatworthy
log -n/--level-count N option |
1177 |
formatter = log.LineLogFormatter(to_file=logfile, levels=0) |
3947.1.2
by Ian Clatworthy
formatter tests |
1178 |
log.show_log(wt.branch, formatter) |
1179 |
self.assertEqualDiff("""\ |
|
3983.2.1
by Neil Martinsen-Burrell
add merge indication to the line format |
1180 |
2: Joe Foo 2005-11-22 [merge] rev-2
|
3947.1.2
by Ian Clatworthy
formatter tests |
1181 |
1.1.1: Joe Foo 2005-11-22 rev-merged
|
1182 |
1: Joe Foo 2005-11-22 rev-1
|
|
1183 |
""", |
|
1184 |
logfile.getvalue()) |
|
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
1185 |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1186 |
class TestGetViewRevisions(tests.TestCaseWithTransport): |
2466.11.2
by Kent Gibson
Add tests for deltas in merge revisions |
1187 |
|
1756.2.22
by Aaron Bentley
Apply review comments |
1188 |
def make_tree_with_commits(self): |
1189 |
"""Create a tree with well-known revision ids""" |
|
1756.2.20
by Aaron Bentley
Optimize log formats that don't show merges |
1190 |
wt = self.make_branch_and_tree('tree1') |
1191 |
wt.commit('commit one', rev_id='1') |
|
1192 |
wt.commit('commit two', rev_id='2') |
|
1193 |
wt.commit('commit three', rev_id='3') |
|
1194 |
mainline_revs = [None, '1', '2', '3'] |
|
1756.2.22
by Aaron Bentley
Apply review comments |
1195 |
rev_nos = {'1': 1, '2': 2, '3': 3} |
1196 |
return mainline_revs, rev_nos, wt |
|
1197 |
||
1198 |
def make_tree_with_merges(self): |
|
1199 |
"""Create a tree with well-known revision ids and a merge""" |
|
1200 |
mainline_revs, rev_nos, wt = self.make_tree_with_commits() |
|
1756.2.20
by Aaron Bentley
Optimize log formats that don't show merges |
1201 |
tree2 = wt.bzrdir.sprout('tree2').open_workingtree() |
1202 |
tree2.commit('four-a', rev_id='4a') |
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
1203 |
wt.merge_from_branch(tree2.branch) |
1756.2.20
by Aaron Bentley
Optimize log formats that don't show merges |
1204 |
wt.commit('four-b', rev_id='4b') |
1205 |
mainline_revs.append('4b') |
|
1756.2.22
by Aaron Bentley
Apply review comments |
1206 |
rev_nos['4b'] = 4 |
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1207 |
# 4a: 3.1.1
|
1756.2.22
by Aaron Bentley
Apply review comments |
1208 |
return mainline_revs, rev_nos, wt |
1209 |
||
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1210 |
def make_tree_with_many_merges(self): |
1211 |
"""Create a tree with well-known revision ids""" |
|
1212 |
wt = self.make_branch_and_tree('tree1') |
|
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1213 |
self.build_tree_contents([('tree1/f', '1\n')]) |
1214 |
wt.add(['f'], ['f-id']) |
|
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1215 |
wt.commit('commit one', rev_id='1') |
1216 |
wt.commit('commit two', rev_id='2') |
|
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1217 |
|
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1218 |
tree3 = wt.bzrdir.sprout('tree3').open_workingtree() |
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1219 |
self.build_tree_contents([('tree3/f', '1\n2\n3a\n')]) |
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1220 |
tree3.commit('commit three a', rev_id='3a') |
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1221 |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1222 |
tree2 = wt.bzrdir.sprout('tree2').open_workingtree() |
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
1223 |
tree2.merge_from_branch(tree3.branch) |
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1224 |
tree2.commit('commit three b', rev_id='3b') |
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1225 |
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
1226 |
wt.merge_from_branch(tree2.branch) |
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1227 |
wt.commit('commit three c', rev_id='3c') |
1228 |
tree2.commit('four-a', rev_id='4a') |
|
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1229 |
|
1979.2.1
by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree. |
1230 |
wt.merge_from_branch(tree2.branch) |
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1231 |
wt.commit('four-b', rev_id='4b') |
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1232 |
|
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1233 |
mainline_revs = [None, '1', '2', '3c', '4b'] |
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1234 |
rev_nos = {'1':1, '2':2, '3c': 3, '4b':4} |
1235 |
full_rev_nos_for_reference = { |
|
1236 |
'1': '1', |
|
1237 |
'2': '2', |
|
3170.3.4
by John Arbash Meinel
Update the tests for the new revision numbering. |
1238 |
'3a': '2.1.1', #first commit tree 3 |
1239 |
'3b': '2.2.1', # first commit tree 2 |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1240 |
'3c': '3', #merges 3b to main |
3170.3.4
by John Arbash Meinel
Update the tests for the new revision numbering. |
1241 |
'4a': '2.2.2', # second commit tree 2 |
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1242 |
'4b': '4', # merges 4a to main |
1243 |
}
|
|
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1244 |
return mainline_revs, rev_nos, wt |
1245 |
||
1756.2.22
by Aaron Bentley
Apply review comments |
1246 |
def test_get_view_revisions_forward(self): |
1247 |
"""Test the get_view_revisions method""" |
|
1248 |
mainline_revs, rev_nos, wt = self.make_tree_with_commits() |
|
3287.6.1
by Robert Collins
* ``VersionedFile.get_graph`` is deprecated, with no replacement method. |
1249 |
wt.lock_read() |
1250 |
self.addCleanup(wt.unlock) |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1251 |
revisions = list(log.get_view_revisions( |
1252 |
mainline_revs, rev_nos, wt.branch, 'forward')) |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1253 |
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0)], |
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1254 |
revisions) |
1255 |
revisions2 = list(log.get_view_revisions( |
|
1256 |
mainline_revs, rev_nos, wt.branch, 'forward', |
|
1257 |
include_merges=False)) |
|
1756.2.22
by Aaron Bentley
Apply review comments |
1258 |
self.assertEqual(revisions, revisions2) |
1259 |
||
1260 |
def test_get_view_revisions_reverse(self): |
|
1261 |
"""Test the get_view_revisions with reverse""" |
|
1262 |
mainline_revs, rev_nos, wt = self.make_tree_with_commits() |
|
3287.6.1
by Robert Collins
* ``VersionedFile.get_graph`` is deprecated, with no replacement method. |
1263 |
wt.lock_read() |
1264 |
self.addCleanup(wt.unlock) |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1265 |
revisions = list(log.get_view_revisions( |
1266 |
mainline_revs, rev_nos, wt.branch, 'reverse')) |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1267 |
self.assertEqual([('3', '3', 0), ('2', '2', 0), ('1', '1', 0), ], |
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1268 |
revisions) |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1269 |
revisions2 = list(log.get_view_revisions( |
1270 |
mainline_revs, rev_nos, wt.branch, 'reverse', |
|
1271 |
include_merges=False)) |
|
1756.2.22
by Aaron Bentley
Apply review comments |
1272 |
self.assertEqual(revisions, revisions2) |
1273 |
||
1274 |
def test_get_view_revisions_merge(self): |
|
1275 |
"""Test get_view_revisions when there are merges""" |
|
1276 |
mainline_revs, rev_nos, wt = self.make_tree_with_merges() |
|
3287.6.1
by Robert Collins
* ``VersionedFile.get_graph`` is deprecated, with no replacement method. |
1277 |
wt.lock_read() |
1278 |
self.addCleanup(wt.unlock) |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1279 |
revisions = list(log.get_view_revisions( |
1280 |
mainline_revs, rev_nos, wt.branch, 'forward')) |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1281 |
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0), |
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1282 |
('4b', '4', 0), ('4a', '3.1.1', 1)], |
1283 |
revisions) |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1284 |
revisions = list(log.get_view_revisions( |
1285 |
mainline_revs, rev_nos, wt.branch, 'forward', |
|
1286 |
include_merges=False)) |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1287 |
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0), |
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1288 |
('4b', '4', 0)], |
1289 |
revisions) |
|
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1290 |
|
1291 |
def test_get_view_revisions_merge_reverse(self): |
|
1292 |
"""Test get_view_revisions in reverse when there are merges""" |
|
1293 |
mainline_revs, rev_nos, wt = self.make_tree_with_merges() |
|
3287.6.1
by Robert Collins
* ``VersionedFile.get_graph`` is deprecated, with no replacement method. |
1294 |
wt.lock_read() |
1295 |
self.addCleanup(wt.unlock) |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1296 |
revisions = list(log.get_view_revisions( |
1297 |
mainline_revs, rev_nos, wt.branch, 'reverse')) |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1298 |
self.assertEqual([('4b', '4', 0), ('4a', '3.1.1', 1), |
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1299 |
('3', '3', 0), ('2', '2', 0), ('1', '1', 0)], |
1300 |
revisions) |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1301 |
revisions = list(log.get_view_revisions( |
1302 |
mainline_revs, rev_nos, wt.branch, 'reverse', |
|
1303 |
include_merges=False)) |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1304 |
self.assertEqual([('4b', '4', 0), ('3', '3', 0), ('2', '2', 0), |
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1305 |
('1', '1', 0)], |
1306 |
revisions) |
|
1756.2.24
by Aaron Bentley
Forward sorting shows merges under mainline revision |
1307 |
|
1308 |
def test_get_view_revisions_merge2(self): |
|
1309 |
"""Test get_view_revisions when there are merges""" |
|
1310 |
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges() |
|
3287.6.1
by Robert Collins
* ``VersionedFile.get_graph`` is deprecated, with no replacement method. |
1311 |
wt.lock_read() |
1312 |
self.addCleanup(wt.unlock) |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1313 |
revisions = list(log.get_view_revisions( |
1314 |
mainline_revs, rev_nos, wt.branch, 'forward')) |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1315 |
expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0), |
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1316 |
('3a', '2.1.1', 1), ('3b', '2.2.1', 1), ('4b', '4', 0), |
1317 |
('4a', '2.2.2', 1)] |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1318 |
self.assertEqual(expected, revisions) |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1319 |
revisions = list(log.get_view_revisions( |
1320 |
mainline_revs, rev_nos, wt.branch, 'forward', |
|
1321 |
include_merges=False)) |
|
1988.4.2
by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions, |
1322 |
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0), |
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1323 |
('4b', '4', 0)], |
1324 |
revisions) |
|
2359.1.6
by John Arbash Meinel
Create a helper tree which has a semi-interesting history. |
1325 |
|
1326 |
||
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1327 |
def test_file_id_for_range(self): |
1328 |
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges() |
|
1329 |
wt.lock_read() |
|
1330 |
self.addCleanup(wt.unlock) |
|
1331 |
||
1332 |
def rev_from_rev_id(revid, branch): |
|
1333 |
revspec = revisionspec.RevisionSpec.from_string('revid:%s' % revid) |
|
1334 |
return revspec.in_history(branch) |
|
1335 |
||
1336 |
def view_revs(start_rev, end_rev, file_id, direction): |
|
1337 |
revs = log.calculate_view_revisions( |
|
1338 |
wt.branch, |
|
1339 |
start_rev, # start_revision |
|
1340 |
end_rev, # end_revision |
|
1341 |
direction, # direction |
|
1342 |
file_id, # specific_fileid |
|
1343 |
True, # generate_merge_revisions |
|
1344 |
True, # allow_single_merge_revision |
|
1345 |
)
|
|
1346 |
return revs |
|
1347 |
||
1348 |
rev_3a = rev_from_rev_id('3a', wt.branch) |
|
1349 |
rev_4b = rev_from_rev_id('4b', wt.branch) |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
1350 |
self.assertEqual([('3c', '3', 0), ('3a', '2.1.1', 1)], |
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1351 |
view_revs(rev_3a, rev_4b, 'f-id', 'reverse')) |
3936.3.30
by Ian Clatworthy
use iter_merge_sorted_revisions() with stop_range feature |
1352 |
# Note: 3c still appears before 3a here because of depth-based sorting
|
1353 |
self.assertEqual([('3c', '3', 0), ('3a', '2.1.1', 1)], |
|
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1354 |
view_revs(rev_3a, rev_4b, 'f-id', 'forward')) |
1355 |
||
1356 |
||
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1357 |
class TestGetRevisionsTouchingFileID(tests.TestCaseWithTransport): |
2359.1.6
by John Arbash Meinel
Create a helper tree which has a semi-interesting history. |
1358 |
|
1359 |
def create_tree_with_single_merge(self): |
|
1360 |
"""Create a branch with a moderate layout. |
|
1361 |
||
1362 |
The revision graph looks like:
|
|
1363 |
||
1364 |
A
|
|
1365 |
|\
|
|
1366 |
B C
|
|
1367 |
|/
|
|
1368 |
D
|
|
1369 |
||
1370 |
In this graph, A introduced files f1 and f2 and f3.
|
|
1371 |
B modifies f1 and f3, and C modifies f2 and f3.
|
|
1372 |
D merges the changes from B and C and resolves the conflict for f3.
|
|
1373 |
"""
|
|
1374 |
# TODO: jam 20070218 This seems like it could really be done
|
|
1375 |
# with make_branch_and_memory_tree() if we could just
|
|
1376 |
# create the content of those files.
|
|
1377 |
# TODO: jam 20070218 Another alternative is that we would really
|
|
1378 |
# like to only create this tree 1 time for all tests that
|
|
1379 |
# use it. Since 'log' only uses the tree in a readonly
|
|
1380 |
# fashion, it seems a shame to regenerate an identical
|
|
1381 |
# tree for each test.
|
|
1382 |
tree = self.make_branch_and_tree('tree') |
|
1383 |
tree.lock_write() |
|
1384 |
self.addCleanup(tree.unlock) |
|
1385 |
||
1386 |
self.build_tree_contents([('tree/f1', 'A\n'), |
|
1387 |
('tree/f2', 'A\n'), |
|
1388 |
('tree/f3', 'A\n'), |
|
1389 |
])
|
|
1390 |
tree.add(['f1', 'f2', 'f3'], ['f1-id', 'f2-id', 'f3-id']) |
|
1391 |
tree.commit('A', rev_id='A') |
|
1392 |
||
1393 |
self.build_tree_contents([('tree/f2', 'A\nC\n'), |
|
1394 |
('tree/f3', 'A\nC\n'), |
|
1395 |
])
|
|
1396 |
tree.commit('C', rev_id='C') |
|
1397 |
# Revert back to A to build the other history.
|
|
1398 |
tree.set_last_revision('A') |
|
1399 |
tree.branch.set_last_revision_info(1, 'A') |
|
1400 |
self.build_tree_contents([('tree/f1', 'A\nB\n'), |
|
1401 |
('tree/f2', 'A\n'), |
|
1402 |
('tree/f3', 'A\nB\n'), |
|
1403 |
])
|
|
1404 |
tree.commit('B', rev_id='B') |
|
1405 |
tree.set_parent_ids(['B', 'C']) |
|
1406 |
self.build_tree_contents([('tree/f1', 'A\nB\n'), |
|
1407 |
('tree/f2', 'A\nC\n'), |
|
1408 |
('tree/f3', 'A\nB\nC\n'), |
|
1409 |
])
|
|
1410 |
tree.commit('D', rev_id='D') |
|
1411 |
||
1412 |
# Switch to a read lock for this tree.
|
|
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1413 |
# We still have an addCleanup(tree.unlock) pending
|
2359.1.6
by John Arbash Meinel
Create a helper tree which has a semi-interesting history. |
1414 |
tree.unlock() |
1415 |
tree.lock_read() |
|
1416 |
return tree |
|
1417 |
||
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1418 |
def check_delta(self, delta, **kw): |
1419 |
"""Check the filenames touched by a delta are as expected. |
|
1420 |
||
1421 |
Caller only have to pass in the list of files for each part, all
|
|
1422 |
unspecified parts are considered empty (and checked as such).
|
|
1423 |
"""
|
|
1424 |
for n in 'added', 'removed', 'renamed', 'modified', 'unchanged': |
|
1425 |
# By default we expect an empty list
|
|
1426 |
expected = kw.get(n, []) |
|
1427 |
# strip out only the path components
|
|
1428 |
got = [x[0] for x in getattr(delta, n)] |
|
3842.2.7
by Vincent Ladeuil
Fixed as per Jonh's review. |
1429 |
self.assertEqual(expected, got) |
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1430 |
|
2359.1.6
by John Arbash Meinel
Create a helper tree which has a semi-interesting history. |
1431 |
def test_tree_with_single_merge(self): |
1432 |
"""Make sure the tree layout is correct.""" |
|
1433 |
tree = self.create_tree_with_single_merge() |
|
1434 |
rev_A_tree = tree.branch.repository.revision_tree('A') |
|
1435 |
rev_B_tree = tree.branch.repository.revision_tree('B') |
|
1436 |
rev_C_tree = tree.branch.repository.revision_tree('C') |
|
1437 |
rev_D_tree = tree.branch.repository.revision_tree('D') |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1438 |
|
1439 |
self.check_delta(rev_B_tree.changes_from(rev_A_tree), |
|
1440 |
modified=['f1', 'f3']) |
|
1441 |
||
1442 |
self.check_delta(rev_C_tree.changes_from(rev_A_tree), |
|
1443 |
modified=['f2', 'f3']) |
|
1444 |
||
1445 |
self.check_delta(rev_D_tree.changes_from(rev_B_tree), |
|
1446 |
modified=['f2', 'f3']) |
|
1447 |
||
1448 |
self.check_delta(rev_D_tree.changes_from(rev_C_tree), |
|
1449 |
modified=['f1', 'f3']) |
|
2359.1.6
by John Arbash Meinel
Create a helper tree which has a semi-interesting history. |
1450 |
|
2359.1.7
by John Arbash Meinel
Create a direct test for _get_revisions_touching_file_id |
1451 |
def assertAllRevisionsForFileID(self, tree, file_id, revisions): |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1452 |
"""Ensure _filter_revisions_touching_file_id returns the right values. |
2359.1.7
by John Arbash Meinel
Create a direct test for _get_revisions_touching_file_id |
1453 |
|
2466.12.1
by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions. |
1454 |
Get the return value from _filter_revisions_touching_file_id and make
|
2359.1.7
by John Arbash Meinel
Create a direct test for _get_revisions_touching_file_id |
1455 |
sure they are correct.
|
1456 |
"""
|
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1457 |
# The api for _filter_revisions_touching_file_id is a little crazy.
|
2359.1.7
by John Arbash Meinel
Create a direct test for _get_revisions_touching_file_id |
1458 |
# So we do the setup here.
|
1459 |
mainline = tree.branch.revision_history() |
|
1460 |
mainline.insert(0, None) |
|
1461 |
revnos = dict((rev, idx+1) for idx, rev in enumerate(mainline)) |
|
1462 |
view_revs_iter = log.get_view_revisions(mainline, revnos, tree.branch, |
|
1463 |
'reverse', True) |
|
2466.12.1
by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions. |
1464 |
actual_revs = log._filter_revisions_touching_file_id( |
3711.3.23
by John Arbash Meinel
Documentation and cleanup. |
1465 |
tree.branch, |
2466.12.1
by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions. |
1466 |
file_id, |
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
1467 |
list(view_revs_iter)) |
2359.1.7
by John Arbash Meinel
Create a direct test for _get_revisions_touching_file_id |
1468 |
self.assertEqual(revisions, [r for r, revno, depth in actual_revs]) |
1469 |
||
1470 |
def test_file_id_f1(self): |
|
1471 |
tree = self.create_tree_with_single_merge() |
|
1472 |
# f1 should be marked as modified by revisions A and B
|
|
1473 |
self.assertAllRevisionsForFileID(tree, 'f1-id', ['B', 'A']) |
|
1474 |
||
1475 |
def test_file_id_f2(self): |
|
1476 |
tree = self.create_tree_with_single_merge() |
|
1477 |
# f2 should be marked as modified by revisions A, C, and D
|
|
1478 |
# because D merged the changes from C.
|
|
1479 |
self.assertAllRevisionsForFileID(tree, 'f2-id', ['D', 'C', 'A']) |
|
1480 |
||
1481 |
def test_file_id_f3(self): |
|
1482 |
tree = self.create_tree_with_single_merge() |
|
1483 |
# f3 should be marked as modified by revisions A, B, C, and D
|
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1484 |
self.assertAllRevisionsForFileID(tree, 'f3-id', ['D', 'C', 'B', 'A']) |
1551.17.2
by Aaron Bentley
Stop showing deltas in pull -v output |
1485 |
|
3373.2.1
by John Arbash Meinel
Fix bug #209948, properly skip over ghosts when displaying the changes for a single file. |
1486 |
def test_file_id_with_ghosts(self): |
1487 |
# This is testing bug #209948, where having a ghost would cause
|
|
1488 |
# _filter_revisions_touching_file_id() to fail.
|
|
1489 |
tree = self.create_tree_with_single_merge() |
|
1490 |
# We need to add a revision, so switch back to a write-locked tree
|
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1491 |
# (still a single addCleanup(tree.unlock) pending).
|
3373.2.1
by John Arbash Meinel
Fix bug #209948, properly skip over ghosts when displaying the changes for a single file. |
1492 |
tree.unlock() |
1493 |
tree.lock_write() |
|
1494 |
first_parent = tree.last_revision() |
|
1495 |
tree.set_parent_ids([first_parent, 'ghost-revision-id']) |
|
1496 |
self.build_tree_contents([('tree/f1', 'A\nB\nXX\n')]) |
|
1497 |
tree.commit('commit with a ghost', rev_id='XX') |
|
1498 |
self.assertAllRevisionsForFileID(tree, 'f1-id', ['XX', 'B', 'A']) |
|
1499 |
self.assertAllRevisionsForFileID(tree, 'f2-id', ['D', 'C', 'A']) |
|
1500 |
||
1551.17.2
by Aaron Bentley
Stop showing deltas in pull -v output |
1501 |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1502 |
class TestShowChangedRevisions(tests.TestCaseWithTransport): |
1551.17.2
by Aaron Bentley
Stop showing deltas in pull -v output |
1503 |
|
1504 |
def test_show_changed_revisions_verbose(self): |
|
1505 |
tree = self.make_branch_and_tree('tree_a') |
|
1506 |
self.build_tree(['tree_a/foo']) |
|
1507 |
tree.add('foo') |
|
1508 |
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. |
1509 |
s = self.make_utf8_encoded_stringio() |
1551.17.2
by Aaron Bentley
Stop showing deltas in pull -v output |
1510 |
log.show_changed_revisions(tree.branch, [], ['bar-id'], s) |
1511 |
self.assertContainsRe(s.getvalue(), 'bar') |
|
1512 |
self.assertNotContainsRe(s.getvalue(), 'foo') |
|
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1513 |
|
1514 |
||
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1515 |
class TestLogFormatter(tests.TestCase): |
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1516 |
|
1517 |
def test_short_committer(self): |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1518 |
rev = revision.Revision('a-id') |
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1519 |
rev.committer = 'John Doe <jdoe@example.com>' |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1520 |
lf = log.LogFormatter(None) |
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1521 |
self.assertEqual('John Doe', lf.short_committer(rev)) |
3063.3.1
by Lukáš Lalinský
Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail. |
1522 |
rev.committer = 'John Smith <jsmith@example.com>' |
3063.3.3
by Lukáš Lalinský
Add one more test for config.parse_username(). |
1523 |
self.assertEqual('John Smith', lf.short_committer(rev)) |
3063.3.1
by Lukáš Lalinský
Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail. |
1524 |
rev.committer = 'John Smith' |
3063.3.3
by Lukáš Lalinský
Add one more test for config.parse_username(). |
1525 |
self.assertEqual('John Smith', lf.short_committer(rev)) |
3063.3.1
by Lukáš Lalinský
Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail. |
1526 |
rev.committer = 'jsmith@example.com' |
3063.3.3
by Lukáš Lalinský
Add one more test for config.parse_username(). |
1527 |
self.assertEqual('jsmith@example.com', lf.short_committer(rev)) |
3063.3.1
by Lukáš Lalinský
Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail. |
1528 |
rev.committer = '<jsmith@example.com>' |
3063.3.3
by Lukáš Lalinský
Add one more test for config.parse_username(). |
1529 |
self.assertEqual('jsmith@example.com', lf.short_committer(rev)) |
1530 |
rev.committer = 'John Smith jsmith@example.com' |
|
1531 |
self.assertEqual('John Smith', lf.short_committer(rev)) |
|
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1532 |
|
1533 |
def test_short_author(self): |
|
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1534 |
rev = revision.Revision('a-id') |
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1535 |
rev.committer = 'John Doe <jdoe@example.com>' |
3842.2.1
by Vincent Ladeuil
Cosmetic changes. |
1536 |
lf = log.LogFormatter(None) |
2671.5.8
by Lukáš Lalinsky
Add tests for LogFormatter.short_committer and LogFormatter.short_author. |
1537 |
self.assertEqual('John Doe', lf.short_author(rev)) |
1538 |
rev.properties['author'] = 'John Smith <jsmith@example.com>' |
|
1539 |
self.assertEqual('John Smith', lf.short_author(rev)) |
|
3063.3.1
by Lukáš Lalinský
Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail. |
1540 |
rev.properties['author'] = 'John Smith' |
1541 |
self.assertEqual('John Smith', lf.short_author(rev)) |
|
1542 |
rev.properties['author'] = 'jsmith@example.com' |
|
1543 |
self.assertEqual('jsmith@example.com', lf.short_author(rev)) |
|
1544 |
rev.properties['author'] = '<jsmith@example.com>' |
|
1545 |
self.assertEqual('jsmith@example.com', lf.short_author(rev)) |
|
3063.3.3
by Lukáš Lalinský
Add one more test for config.parse_username(). |
1546 |
rev.properties['author'] = 'John Smith jsmith@example.com' |
1547 |
self.assertEqual('John Smith', lf.short_author(rev)) |
|
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1548 |
|
1549 |
||
1550 |
class TestReverseByDepth(tests.TestCase): |
|
1551 |
"""Test reverse_by_depth behavior. |
|
1552 |
||
1553 |
This is used to present revisions in forward (oldest first) order in a nice
|
|
1554 |
layout.
|
|
1555 |
||
1556 |
The tests use lighter revision description to ease reading.
|
|
1557 |
"""
|
|
1558 |
||
1559 |
def assertReversed(self, forward, backward): |
|
1560 |
# Transform the descriptions to suit the API: tests use (revno, depth),
|
|
1561 |
# while the API expects (revid, revno, depth)
|
|
1562 |
def complete_revisions(l): |
|
1563 |
"""Transform the description to suit the API. |
|
1564 |
||
1565 |
Tests use (revno, depth) whil the API expects (revid, revno, depth).
|
|
1566 |
Since the revid is arbitrary, we just duplicate revno
|
|
1567 |
"""
|
|
1568 |
return [ (r, r, d) for r, d in l] |
|
1569 |
forward = complete_revisions(forward) |
|
1570 |
backward= complete_revisions(backward) |
|
1571 |
self.assertEqual(forward, log.reverse_by_depth(backward)) |
|
1572 |
||
1573 |
||
1574 |
def test_mainline_revisions(self): |
|
1575 |
self.assertReversed([( '1', 0), ('2', 0)], |
|
1576 |
[('2', 0), ('1', 0)]) |
|
1577 |
||
1578 |
def test_merged_revisions(self): |
|
3842.2.3
by Vincent Ladeuil
Yet more cleanup and fix test_file_id_f3 bogus test. |
1579 |
self.assertReversed([('1', 0), ('2', 0), ('2.2', 1), ('2.1', 1),], |
1580 |
[('2', 0), ('2.1', 1), ('2.2', 1), ('1', 0),]) |
|
3842.2.2
by Vincent Ladeuil
Reproduce bug #300055. |
1581 |
def test_shifted_merged_revisions(self): |
1582 |
"""Test irregular layout. |
|
1583 |
||
1584 |
Requesting revisions touching a file can produce "holes" in the depths.
|
|
1585 |
"""
|
|
1586 |
self.assertReversed([('1', 0), ('2', 0), ('1.1', 2), ('1.2', 2),], |
|
1587 |
[('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. |
1588 |
|
1589 |
def test_merged_without_child_revisions(self): |
|
1590 |
"""Test irregular layout. |
|
1591 |
||
1592 |
Revision ranges can produce "holes" in the depths.
|
|
1593 |
"""
|
|
1594 |
# When a revision of higher depth doesn't follow one of lower depth, we
|
|
1595 |
# assume a lower depth one is virtually there
|
|
1596 |
self.assertReversed([('1', 2), ('2', 2), ('3', 3), ('4', 4)], |
|
1597 |
[('4', 4), ('3', 3), ('2', 2), ('1', 2),]) |
|
1598 |
# So we get the same order after reversing below even if the original
|
|
1599 |
# revisions are not in the same order.
|
|
1600 |
self.assertReversed([('1', 2), ('2', 2), ('3', 3), ('4', 4)], |
|
1601 |
[('3', 3), ('4', 4), ('2', 2), ('1', 2),]) |
|
3848.1.6
by Aaron Bentley
Implement get_history_change |
1602 |
|
1603 |
||
3848.1.8
by Aaron Bentley
Implement basic show_branch_change |
1604 |
class TestHistoryChange(tests.TestCaseWithTransport): |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1605 |
|
1606 |
def setup_a_tree(self): |
|
1607 |
tree = self.make_branch_and_tree('tree') |
|
1608 |
tree.lock_write() |
|
1609 |
self.addCleanup(tree.unlock) |
|
1610 |
tree.commit('1a', rev_id='1a') |
|
1611 |
tree.commit('2a', rev_id='2a') |
|
1612 |
tree.commit('3a', rev_id='3a') |
|
1613 |
return tree |
|
1614 |
||
1615 |
def setup_ab_tree(self): |
|
1616 |
tree = self.setup_a_tree() |
|
1617 |
tree.set_last_revision('1a') |
|
1618 |
tree.branch.set_last_revision_info(1, '1a') |
|
1619 |
tree.commit('2b', rev_id='2b') |
|
1620 |
tree.commit('3b', rev_id='3b') |
|
1621 |
return tree |
|
1622 |
||
1623 |
def setup_ac_tree(self): |
|
1624 |
tree = self.setup_a_tree() |
|
1625 |
tree.set_last_revision(revision.NULL_REVISION) |
|
1626 |
tree.branch.set_last_revision_info(0, revision.NULL_REVISION) |
|
1627 |
tree.commit('1c', rev_id='1c') |
|
1628 |
tree.commit('2c', rev_id='2c') |
|
1629 |
tree.commit('3c', rev_id='3c') |
|
1630 |
return tree |
|
1631 |
||
1632 |
def test_all_new(self): |
|
1633 |
tree = self.setup_ab_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1634 |
old, new = log.get_history_change('1a', '3a', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1635 |
self.assertEqual([], old) |
1636 |
self.assertEqual(['2a', '3a'], new) |
|
1637 |
||
1638 |
def test_all_old(self): |
|
1639 |
tree = self.setup_ab_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1640 |
old, new = log.get_history_change('3a', '1a', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1641 |
self.assertEqual([], new) |
1642 |
self.assertEqual(['2a', '3a'], old) |
|
1643 |
||
1644 |
def test_null_old(self): |
|
1645 |
tree = self.setup_ab_tree() |
|
1646 |
old, new = log.get_history_change(revision.NULL_REVISION, |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1647 |
'3a', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1648 |
self.assertEqual([], old) |
1649 |
self.assertEqual(['1a', '2a', '3a'], new) |
|
1650 |
||
1651 |
def test_null_new(self): |
|
1652 |
tree = self.setup_ab_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1653 |
old, new = log.get_history_change('3a', revision.NULL_REVISION, |
1654 |
tree.branch.repository) |
|
3848.1.6
by Aaron Bentley
Implement get_history_change |
1655 |
self.assertEqual([], new) |
1656 |
self.assertEqual(['1a', '2a', '3a'], old) |
|
1657 |
||
1658 |
def test_diverged(self): |
|
1659 |
tree = self.setup_ab_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1660 |
old, new = log.get_history_change('3a', '3b', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1661 |
self.assertEqual(old, ['2a', '3a']) |
1662 |
self.assertEqual(new, ['2b', '3b']) |
|
1663 |
||
1664 |
def test_unrelated(self): |
|
1665 |
tree = self.setup_ac_tree() |
|
3848.1.7
by Aaron Bentley
Use repository in get_history_change |
1666 |
old, new = log.get_history_change('3a', '3c', tree.branch.repository) |
3848.1.6
by Aaron Bentley
Implement get_history_change |
1667 |
self.assertEqual(old, ['1a', '2a', '3a']) |
1668 |
self.assertEqual(new, ['1c', '2c', '3c']) |
|
3848.1.8
by Aaron Bentley
Implement basic show_branch_change |
1669 |
|
1670 |
def test_show_branch_change(self): |
|
1671 |
tree = self.setup_ab_tree() |
|
1672 |
s = StringIO() |
|
3848.1.12
by Aaron Bentley
Fix test parameter order |
1673 |
log.show_branch_change(tree.branch, s, 3, '3a') |
3848.1.8
by Aaron Bentley
Implement basic show_branch_change |
1674 |
self.assertContainsRe(s.getvalue(), |
1675 |
'[*]{60}\nRemoved Revisions:\n(.|\n)*2a(.|\n)*3a(.|\n)*' |
|
1676 |
'[*]{60}\n\nAdded Revisions:\n(.|\n)*2b(.|\n)*3b') |
|
1677 |
||
1678 |
def test_show_branch_change_no_change(self): |
|
1679 |
tree = self.setup_ab_tree() |
|
1680 |
s = StringIO() |
|
3848.1.12
by Aaron Bentley
Fix test parameter order |
1681 |
log.show_branch_change(tree.branch, s, 3, '3b') |
3848.1.8
by Aaron Bentley
Implement basic show_branch_change |
1682 |
self.assertEqual(s.getvalue(), |
1683 |
'Nothing seems to have changed\n') |
|
1684 |
||
3848.1.9
by Aaron Bentley
new/old sections are omitted as appropriate. |
1685 |
def test_show_branch_change_no_old(self): |
1686 |
tree = self.setup_ab_tree() |
|
1687 |
s = StringIO() |
|
3848.1.12
by Aaron Bentley
Fix test parameter order |
1688 |
log.show_branch_change(tree.branch, s, 2, '2b') |
3848.1.9
by Aaron Bentley
new/old sections are omitted as appropriate. |
1689 |
self.assertContainsRe(s.getvalue(), 'Added Revisions:') |
1690 |
self.assertNotContainsRe(s.getvalue(), 'Removed Revisions:') |
|
1691 |
||
1692 |
def test_show_branch_change_no_new(self): |
|
1693 |
tree = self.setup_ab_tree() |
|
1694 |
tree.branch.set_last_revision_info(2, '2b') |
|
1695 |
s = StringIO() |
|
3848.1.12
by Aaron Bentley
Fix test parameter order |
1696 |
log.show_branch_change(tree.branch, s, 3, '3b') |
3848.1.9
by Aaron Bentley
new/old sections are omitted as appropriate. |
1697 |
self.assertContainsRe(s.getvalue(), 'Removed Revisions:') |
1698 |
self.assertNotContainsRe(s.getvalue(), 'Added Revisions:') |