50
47
self.assertTrue('message:\n message2\n' in self.full_log)
51
48
self.assertTrue('message:\n message3\n' in self.full_log)
53
log = self.run_bzr("log -r 1..")[0]
54
self.assertEqualDiff(log, self.full_log)
50
log = self.runbzr("log -r 1..")[0]
51
self.assertEquals(log, self.full_log)
56
53
def test_log_null_begin_revspec(self):
58
log = self.run_bzr("log -r ..3")[0]
59
self.assertEqualDiff(self.full_log, log)
55
log = self.runbzr("log -r ..3")[0]
56
self.assertEquals(self.full_log, log)
61
58
def test_log_null_both_revspecs(self):
63
log = self.run_bzr("log -r ..")[0]
60
log = self.runbzr("log -r ..")[0]
64
61
self.assertEquals(self.full_log, log)
65
self.assertEqualDiff(self.full_log, log)
67
63
def test_log_negative_begin_revspec_full_log(self):
69
log = self.run_bzr("log -r -3..")[0]
70
self.assertEqualDiff(self.full_log, log)
65
log = self.runbzr("log -r -3..")[0]
66
self.assertEquals(self.full_log, log)
72
68
def test_log_negative_both_revspec_full_log(self):
74
log = self.run_bzr("log -r -3..-1")[0]
75
self.assertEqualDiff(self.full_log, log)
70
log = self.runbzr("log -r -3..-1")[0]
71
self.assertEquals(self.full_log, log)
77
73
def test_log_negative_both_revspec_partial(self):
79
log = self.run_bzr("log -r -3..-2")[0]
75
log = self.runbzr("log -r -3..-2")[0]
80
76
self.assertTrue('revno: 1\n' in log)
81
77
self.assertTrue('revno: 2\n' in log)
82
78
self.assertTrue('revno: 3\n' not in log)
84
80
def test_log_negative_begin_revspec(self):
86
log = self.run_bzr("log -r -2..")[0]
82
log = self.runbzr("log -r -2..")[0]
87
83
self.assertTrue('revno: 1\n' not in log)
88
84
self.assertTrue('revno: 2\n' in log)
89
85
self.assertTrue('revno: 3\n' in log)
91
87
def test_log_postive_revspecs(self):
93
log = self.run_bzr("log -r 1..3")[0]
94
self.assertEqualDiff(self.full_log, log)
96
def test_log_reversed_revspecs(self):
98
self.run_bzr_error(('bzr: ERROR: Start revision must be older than '
99
'the end revision.\n',),
102
def test_log_revno_n_path(self):
111
log = self.run_bzr("log -r revno:2:branch1..revno:3:branch2",
113
log = self.run_bzr("log -r revno:1:branch2..revno:3:branch2")[0]
114
self.assertEqualDiff(self.full_log, log)
115
log = self.run_bzr("log -r revno:1:branch2")[0]
116
self.assertTrue('revno: 1\n' in log)
117
self.assertTrue('revno: 2\n' not in log)
118
self.assertTrue('branch nick: branch2\n' in log)
119
self.assertTrue('branch nick: branch1\n' not in log)
121
def test_log_nonexistent_file(self):
122
# files that don't exist in either the basis tree or working tree
123
# should give an error
124
wt = self.make_branch_and_tree('.')
125
out, err = self.run_bzr('log does-not-exist', retcode=3)
126
self.assertContainsRe(
127
err, 'Path does not have any revision history: does-not-exist')
129
def test_log_with_tags(self):
130
self._prepare(format='dirstate-tags')
131
self.run_bzr('tag -r1 tag1')
132
self.run_bzr('tag -r1 tag1.1')
133
self.run_bzr('tag tag3')
135
log = self.run_bzr("log -r-1")[0]
136
self.assertTrue('tags: tag3' in log)
138
log = self.run_bzr("log -r1")[0]
139
# I guess that we can't know the order of tags in the output
140
# since dicts are unordered, need to check both possibilities
141
self.assertContainsRe(log, r'tags: (tag1, tag1\.1|tag1\.1, tag1)')
143
def test_merged_log_with_tags(self):
146
self._prepare(format='dirstate-tags')
148
self.run_bzr('branch branch1 branch2')
150
self.run_bzr('commit -m foobar --unchanged')
151
self.run_bzr('tag tag1')
152
os.chdir('../branch2')
153
self.run_bzr('merge ../branch1')
154
self.run_bzr(['commit', '-m', 'merge branch 1'])
155
log = self.run_bzr("log -r-1")[0]
156
self.assertContainsRe(log, r' tags: tag1')
157
log = self.run_bzr("log -r3.1.1")[0]
158
self.assertContainsRe(log, r'tags: tag1')
160
def test_log_limit(self):
162
log = self.run_bzr("log --limit 2")[0]
163
self.assertTrue('revno: 1\n' not in log)
164
self.assertTrue('revno: 2\n' in log)
165
self.assertTrue('revno: 3\n' in log)
89
log = self.runbzr("log -r 1..3")[0]
90
self.assertEquals(self.full_log, log)
167
93
class TestLogMerges(ExternalBase):
95
def test_merges_are_indented_by_level(self):
170
96
self.build_tree(['parent/'])
171
self.run_bzr('init parent')
172
self.run_bzr(['commit', '-m', 'first post', '--unchanged', 'parent'])
173
self.run_bzr('branch parent child')
174
self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child'])
175
self.run_bzr('branch child smallerchild')
176
self.run_bzr(['commit', '-m', 'branch 2', '--unchanged',
97
self.run_bzr('init', 'parent')
98
self.run_bzr('commit', '-m', 'first post', '--unchanged', 'parent')
99
self.run_bzr('branch', 'parent', 'child')
100
self.run_bzr('commit', '-m', 'branch 1', '--unchanged', 'child')
101
self.run_bzr('branch', 'child', 'smallerchild')
102
self.run_bzr('commit', '-m', 'branch 2', '--unchanged', 'smallerchild')
178
103
os.chdir('child')
179
self.run_bzr('merge ../smallerchild')
180
self.run_bzr(['commit', '-m', 'merge branch 2'])
104
self.run_bzr('merge', '../smallerchild')
105
self.run_bzr('commit', '-m', 'merge branch 2')
181
106
os.chdir('../parent')
182
self.run_bzr('merge ../child')
183
self.run_bzr(['commit', '-m', 'merge branch 1'])
185
def test_merges_are_indented_by_level(self):
107
self.run_bzr('merge', '../child')
108
self.run_bzr('commit', '-m', 'merge branch 1')
187
109
out,err = self.run_bzr('log')
188
110
# the log will look something like:
189
111
# self.assertEqual("""\
226
148
# but we dont have a nice pattern matcher hooked up yet, so:
227
# we check for the indenting of the commit message and the
229
self.assertTrue('revno: 2' in out)
149
# we check for the indenting of the commit message:
230
150
self.assertTrue(' merge branch 1' in out)
231
self.assertTrue(' revno: 1.1.2' in out)
232
151
self.assertTrue(' merge branch 2' in out)
233
self.assertTrue(' revno: 1.1.1.1' in out)
234
152
self.assertTrue(' branch 2' in out)
235
self.assertTrue(' revno: 1.1.1' in out)
236
153
self.assertTrue(' branch 1' in out)
237
self.assertTrue('revno: 1\n' in out)
238
154
self.assertTrue(' first post' in out)
239
155
self.assertEqual('', err)
241
def test_merges_single_merge_rev(self):
243
out,err = self.run_bzr('log -r1.1.2')
244
# the log will look something like:
245
# self.assertEqual("""\
246
#------------------------------------------------------------
248
#committer: Robert Collins <foo@example.com>
250
#timestamp: Tue 2006-03-28 22:31:40 +1100
253
# ------------------------------------------------------------
255
# committer: Robert Collins <foo@example.com>
256
# branch nick: smallerchild
257
# timestamp: Tue 2006-03-28 22:31:40 +1100
261
# but we dont have a nice pattern matcher hooked up yet, so:
262
# we check for the indenting of the commit message and the
264
self.assertTrue('revno: 2' not in out)
265
self.assertTrue(' merge branch 1' not in out)
266
self.assertTrue('revno: 1.1.2' in out)
267
self.assertTrue(' merge branch 2' in out)
268
self.assertTrue(' revno: 1.1.1.1' in out)
269
self.assertTrue(' branch 2' in out)
270
self.assertTrue('revno: 1.1.1\n' not in out)
271
self.assertTrue(' branch 1' not in out)
272
self.assertTrue('revno: 1\n' not in out)
273
self.assertTrue(' first post' not in out)
274
self.assertEqual('', err)
276
def test_merges_partial_range(self):
278
out,err = self.run_bzr('log -r1.1.1..1.1.2')
279
# the log will look something like:
280
# self.assertEqual("""\
281
#------------------------------------------------------------
283
#committer: Robert Collins <foo@example.com>
285
#timestamp: Tue 2006-03-28 22:31:40 +1100
288
# ------------------------------------------------------------
290
# committer: Robert Collins <foo@example.com>
291
# branch nick: smallerchild
292
# timestamp: Tue 2006-03-28 22:31:40 +1100
295
#------------------------------------------------------------
297
#committer: Robert Collins <foo@example.com>
299
#timestamp: Tue 2006-03-28 22:31:40 +1100
303
# but we dont have a nice pattern matcher hooked up yet, so:
304
# we check for the indenting of the commit message and the
306
self.assertTrue('revno: 2' not in out)
307
self.assertTrue(' merge branch 1' not in out)
308
self.assertTrue('revno: 1.1.2' in out)
309
self.assertTrue(' merge branch 2' in out)
310
self.assertTrue(' revno: 1.1.1.1' in out)
311
self.assertTrue(' branch 2' in out)
312
self.assertTrue('revno: 1.1.1' in out)
313
self.assertTrue(' branch 1' in out)
314
self.assertTrue('revno: 1\n' not in out)
315
self.assertTrue(' first post' not in out)
316
self.assertEqual('', err)
319
158
class TestLogEncodings(TestCaseInTempDir):
416
255
# Make sure the cp1251 string is not found anywhere
417
256
self.assertEquals(-1, stdout.find(test_in_cp1251))
420
class TestLogFile(TestCaseWithTransport):
422
def test_log_local_branch_file(self):
423
"""We should be able to log files in local treeless branches"""
424
tree = self.make_branch_and_tree('tree')
425
self.build_tree(['tree/file'])
427
tree.commit('revision 1')
428
tree.bzrdir.destroy_workingtree()
429
self.run_bzr('log tree/file')
431
def test_log_file(self):
432
"""The log for a particular file should only list revs for that file"""
433
tree = self.make_branch_and_tree('parent')
434
self.build_tree(['parent/file1', 'parent/file2', 'parent/file3'])
436
tree.commit('add file1')
438
tree.commit('add file2')
440
tree.commit('add file3')
441
self.run_bzr('branch parent child')
442
print >> file('child/file2', 'wb'), 'hello'
443
self.run_bzr(['commit', '-m', 'branch 1', 'child'])
445
self.run_bzr('merge ../child')
446
self.run_bzr(['commit', '-m', 'merge child branch'])
447
log = self.run_bzr('log file1')[0]
448
self.assertContainsRe(log, 'revno: 1\n')
449
self.assertNotContainsRe(log, 'revno: 2\n')
450
self.assertNotContainsRe(log, 'revno: 3\n')
451
self.assertNotContainsRe(log, 'revno: 3.1.1\n')
452
self.assertNotContainsRe(log, 'revno: 4\n')
453
log = self.run_bzr('log file2')[0]
454
self.assertNotContainsRe(log, 'revno: 1\n')
455
self.assertContainsRe(log, 'revno: 2\n')
456
self.assertNotContainsRe(log, 'revno: 3\n')
457
self.assertContainsRe(log, 'revno: 3.1.1\n')
458
self.assertContainsRe(log, 'revno: 4\n')
459
log = self.run_bzr('log file3')[0]
460
self.assertNotContainsRe(log, 'revno: 1\n')
461
self.assertNotContainsRe(log, 'revno: 2\n')
462
self.assertContainsRe(log, 'revno: 3\n')
463
self.assertNotContainsRe(log, 'revno: 3.1.1\n')
464
self.assertNotContainsRe(log, 'revno: 4\n')
465
log = self.run_bzr('log -r3.1.1 file2')[0]
466
self.assertNotContainsRe(log, 'revno: 1\n')
467
self.assertNotContainsRe(log, 'revno: 2\n')
468
self.assertNotContainsRe(log, 'revno: 3\n')
469
self.assertContainsRe(log, 'revno: 3.1.1\n')
470
self.assertNotContainsRe(log, 'revno: 4\n')
471
log = self.run_bzr('log -r4 file2')[0]
472
self.assertNotContainsRe(log, 'revno: 1\n')
473
self.assertNotContainsRe(log, 'revno: 2\n')
474
self.assertNotContainsRe(log, 'revno: 3\n')
475
self.assertContainsRe(log, 'revno: 3.1.1\n')
476
self.assertContainsRe(log, 'revno: 4\n')
477
log = self.run_bzr('log -r3.. file2')[0]
478
self.assertNotContainsRe(log, 'revno: 1\n')
479
self.assertNotContainsRe(log, 'revno: 2\n')
480
self.assertNotContainsRe(log, 'revno: 3\n')
481
self.assertContainsRe(log, 'revno: 3.1.1\n')
482
self.assertContainsRe(log, 'revno: 4\n')
483
log = self.run_bzr('log -r..3 file2')[0]
484
self.assertNotContainsRe(log, 'revno: 1\n')
485
self.assertContainsRe(log, 'revno: 2\n')
486
self.assertNotContainsRe(log, 'revno: 3\n')
487
self.assertNotContainsRe(log, 'revno: 3.1.1\n')
488
self.assertNotContainsRe(log, 'revno: 4\n')