28
28
class TestLog(ExternalBase):
30
def _prepare(self, format=None):
32
self.run_bzr(["init", "--format="+format])
32
35
self.build_tree(['hello.txt', 'goodbye.txt', 'meep.txt'])
33
self.runbzr("add hello.txt")
34
self.runbzr("commit -m message1 hello.txt")
35
self.runbzr("add goodbye.txt")
36
self.runbzr("commit -m message2 goodbye.txt")
37
self.runbzr("add meep.txt")
38
self.runbzr("commit -m message3 meep.txt")
39
self.full_log = self.runbzr("log")[0]
36
self.run_bzr("add hello.txt")
37
self.run_bzr("commit -m message1 hello.txt")
38
self.run_bzr("add goodbye.txt")
39
self.run_bzr("commit -m message2 goodbye.txt")
40
self.run_bzr("add meep.txt")
41
self.run_bzr("commit -m message3 meep.txt")
42
self.full_log = self.run_bzr("log")[0]
41
44
def test_log_null_end_revspec(self):
47
50
self.assertTrue('message:\n message2\n' in self.full_log)
48
51
self.assertTrue('message:\n message3\n' in self.full_log)
50
log = self.runbzr("log -r 1..")[0]
51
self.assertEquals(log, self.full_log)
53
log = self.run_bzr("log -r 1..")[0]
54
self.assertEqualDiff(log, self.full_log)
53
56
def test_log_null_begin_revspec(self):
55
log = self.runbzr("log -r ..3")[0]
56
self.assertEquals(self.full_log, log)
58
log = self.run_bzr("log -r ..3")[0]
59
self.assertEqualDiff(self.full_log, log)
58
61
def test_log_null_both_revspecs(self):
60
log = self.runbzr("log -r ..")[0]
63
log = self.run_bzr("log -r ..")[0]
61
64
self.assertEquals(self.full_log, log)
65
self.assertEqualDiff(self.full_log, log)
63
67
def test_log_negative_begin_revspec_full_log(self):
65
log = self.runbzr("log -r -3..")[0]
66
self.assertEquals(self.full_log, log)
69
log = self.run_bzr("log -r -3..")[0]
70
self.assertEqualDiff(self.full_log, log)
68
72
def test_log_negative_both_revspec_full_log(self):
70
log = self.runbzr("log -r -3..-1")[0]
71
self.assertEquals(self.full_log, log)
74
log = self.run_bzr("log -r -3..-1")[0]
75
self.assertEqualDiff(self.full_log, log)
73
77
def test_log_negative_both_revspec_partial(self):
75
log = self.runbzr("log -r -3..-2")[0]
79
log = self.run_bzr("log -r -3..-2")[0]
76
80
self.assertTrue('revno: 1\n' in log)
77
81
self.assertTrue('revno: 2\n' in log)
78
82
self.assertTrue('revno: 3\n' not in log)
80
84
def test_log_negative_begin_revspec(self):
82
log = self.runbzr("log -r -2..")[0]
86
log = self.run_bzr("log -r -2..")[0]
83
87
self.assertTrue('revno: 1\n' not in log)
84
88
self.assertTrue('revno: 2\n' in log)
85
89
self.assertTrue('revno: 3\n' in log)
87
91
def test_log_postive_revspecs(self):
89
log = self.runbzr("log -r 1..3")[0]
90
self.assertEquals(self.full_log, log)
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',),
92
102
def test_log_revno_n_path(self):
93
103
os.mkdir('branch1')
98
108
os.chdir('branch2')
101
log = self.runbzr("log -r revno:2:branch1..revno:3:branch2",
111
log = self.run_bzr("log -r revno:2:branch1..revno:3:branch2",
103
log = self.runbzr("log -r revno:1:branch2..revno:3:branch2")[0]
104
self.assertEquals(self.full_log, log)
105
log = self.runbzr("log -r revno:1:branch2")[0]
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]
106
116
self.assertTrue('revno: 1\n' in log)
107
117
self.assertTrue('revno: 2\n' not in log)
108
118
self.assertTrue('branch nick: branch2\n' in log)
112
122
# files that don't exist in either the basis tree or working tree
113
123
# should give an error
114
124
wt = self.make_branch_and_tree('.')
115
out, err = self.run_bzr('log', 'does-not-exist', retcode=3)
125
out, err = self.run_bzr('log does-not-exist', retcode=3)
116
126
self.assertContainsRe(
117
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)
119
167
class TestLogMerges(ExternalBase):
121
def test_merges_are_indented_by_level(self):
122
170
self.build_tree(['parent/'])
123
self.run_bzr('init', 'parent')
124
self.run_bzr('commit', '-m', 'first post', '--unchanged', 'parent')
125
self.run_bzr('branch', 'parent', 'child')
126
self.run_bzr('commit', '-m', 'branch 1', '--unchanged', 'child')
127
self.run_bzr('branch', 'child', 'smallerchild')
128
self.run_bzr('commit', '-m', 'branch 2', '--unchanged', 'smallerchild')
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',
129
178
os.chdir('child')
130
self.run_bzr('merge', '../smallerchild')
131
self.run_bzr('commit', '-m', 'merge branch 2')
179
self.run_bzr('merge ../smallerchild')
180
self.run_bzr(['commit', '-m', 'merge branch 2'])
132
181
os.chdir('../parent')
133
self.run_bzr('merge', '../child')
134
self.run_bzr('commit', '-m', 'merge branch 1')
182
self.run_bzr('merge ../child')
183
self.run_bzr(['commit', '-m', 'merge branch 1'])
185
def test_merges_are_indented_by_level(self):
135
187
out,err = self.run_bzr('log')
136
188
# the log will look something like:
137
189
# self.assertEqual("""\
185
234
self.assertTrue(' branch 2' in out)
186
235
self.assertTrue(' revno: 1.1.1' in out)
187
236
self.assertTrue(' branch 1' in out)
188
self.assertTrue('revno: 1' in out)
237
self.assertTrue('revno: 1\n' in out)
189
238
self.assertTrue(' first post' in out)
190
239
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)
193
319
class TestLogEncodings(TestCaseInTempDir):
301
427
tree.commit('revision 1')
302
428
tree.bzrdir.destroy_workingtree()
303
self.run_bzr('log', 'tree/file')
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')