1
# Copyright (C) 2005 by Canonical Ltd
2
# -*- coding: utf-8 -*-
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
"""Black-box tests for bzr log."""
23
from bzrlib.tests.blackbox import ExternalBase
26
class TestLog(ExternalBase):
30
self.build_tree(['hello.txt', 'goodbye.txt', 'meep.txt'])
31
self.runbzr("add hello.txt")
32
self.runbzr("commit -m message1 hello.txt")
33
self.runbzr("add goodbye.txt")
34
self.runbzr("commit -m message2 goodbye.txt")
35
self.runbzr("add meep.txt")
36
self.runbzr("commit -m message3 meep.txt")
37
self.full_log = self.runbzr("log")[0]
39
def test_log_null_end_revspec(self):
41
self.assertTrue('revno: 1\n' in self.full_log)
42
self.assertTrue('revno: 2\n' in self.full_log)
43
self.assertTrue('revno: 3\n' in self.full_log)
44
self.assertTrue('message:\n message1\n' in self.full_log)
45
self.assertTrue('message:\n message2\n' in self.full_log)
46
self.assertTrue('message:\n message3\n' in self.full_log)
48
log = self.runbzr("log -r 1..")[0]
49
self.assertEquals(log, self.full_log)
51
def test_log_null_begin_revspec(self):
53
log = self.runbzr("log -r ..3")[0]
54
self.assertEquals(self.full_log, log)
56
def test_log_null_both_revspecs(self):
58
log = self.runbzr("log -r ..")[0]
59
self.assertEquals(self.full_log, log)
61
def test_log_negative_begin_revspec_full_log(self):
63
log = self.runbzr("log -r -3..")[0]
64
self.assertEquals(self.full_log, log)
66
def test_log_negative_both_revspec_full_log(self):
68
log = self.runbzr("log -r -3..-1")[0]
69
self.assertEquals(self.full_log, log)
71
def test_log_negative_both_revspec_partial(self):
73
log = self.runbzr("log -r -3..-2")[0]
74
self.assertTrue('revno: 1\n' in log)
75
self.assertTrue('revno: 2\n' in log)
76
self.assertTrue('revno: 3\n' not in log)
78
def test_log_negative_begin_revspec(self):
80
log = self.runbzr("log -r -2..")[0]
81
self.assertTrue('revno: 1\n' not in log)
82
self.assertTrue('revno: 2\n' in log)
83
self.assertTrue('revno: 3\n' in log)
85
def test_log_postive_revspecs(self):
87
log = self.runbzr("log -r 1..3")[0]
88
self.assertEquals(self.full_log, log)
91
class TestLogMerges(ExternalBase):
93
def test_merges_are_indented_by_level(self):
94
self.build_tree(['parent/'])
95
self.run_bzr('init', 'parent')
96
self.run_bzr('commit', '-m', 'first post', '--unchanged', 'parent')
97
self.run_bzr('branch', 'parent', 'child')
98
self.run_bzr('commit', '-m', 'branch 1', '--unchanged', 'child')
99
self.run_bzr('branch', 'child', 'smallerchild')
100
self.run_bzr('commit', '-m', 'branch 2', '--unchanged', 'smallerchild')
102
self.run_bzr('merge', '../smallerchild')
103
self.run_bzr('commit', '-m', 'merge branch 2')
104
os.chdir('../parent')
105
self.run_bzr('merge', '../child')
106
self.run_bzr('commit', '-m', 'merge branch 1')
107
out,err = self.run_bzr('log')
108
# the log will look something like:
109
# self.assertEqual("""\
110
#------------------------------------------------------------
112
#committer: Robert Collins <foo@example.com>
114
#timestamp: Tue 2006-03-28 22:31:40 +1100
117
# ------------------------------------------------------------
118
# merged: foo@example.com-20060328113140-91f43cfb46dc2863
119
# committer: Robert Collins <foo@example.com>
121
# timestamp: Tue 2006-03-28 22:31:40 +1100
124
# ------------------------------------------------------------
125
# merged: foo@example.com-20060328113140-1ba24f850a0ef573
126
# committer: Robert Collins <foo@example.com>
127
# branch nick: smallerchild
128
# timestamp: Tue 2006-03-28 22:31:40 +1100
131
# ------------------------------------------------------------
132
# merged: foo@example.com-20060328113140-5749a4757a8ac792
133
# committer: Robert Collins <foo@example.com>
135
# timestamp: Tue 2006-03-28 22:31:40 +1100
138
#------------------------------------------------------------
140
#committer: Robert Collins <foo@example.com>
142
#timestamp: Tue 2006-03-28 22:31:39 +1100
146
# but we dont have a nice pattern matcher hooked up yet, so:
147
# we check for the indenting of the commit message:
148
self.assertTrue(' merge branch 1' in out)
149
self.assertTrue(' merge branch 2' in out)
150
self.assertTrue(' branch 2' in out)
151
self.assertTrue(' branch 1' in out)
152
self.assertTrue(' first post' in out)
153
self.assertEqual('', err)