89
87
log = self.runbzr("log -r 1..3")[0]
90
88
self.assertEquals(self.full_log, log)
93
class TestLogMerges(ExternalBase):
95
def test_merges_are_indented_by_level(self):
96
self.build_tree(['parent/'])
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')
104
self.run_bzr('merge', '../smallerchild')
105
self.run_bzr('commit', '-m', 'merge branch 2')
106
os.chdir('../parent')
107
self.run_bzr('merge', '../child')
108
self.run_bzr('commit', '-m', 'merge branch 1')
109
out,err = self.run_bzr('log')
110
# the log will look something like:
111
# self.assertEqual("""\
112
#------------------------------------------------------------
114
#committer: Robert Collins <foo@example.com>
116
#timestamp: Tue 2006-03-28 22:31:40 +1100
119
# ------------------------------------------------------------
120
# merged: foo@example.com-20060328113140-91f43cfb46dc2863
121
# committer: Robert Collins <foo@example.com>
123
# timestamp: Tue 2006-03-28 22:31:40 +1100
126
# ------------------------------------------------------------
127
# merged: foo@example.com-20060328113140-1ba24f850a0ef573
128
# committer: Robert Collins <foo@example.com>
129
# branch nick: smallerchild
130
# timestamp: Tue 2006-03-28 22:31:40 +1100
133
# ------------------------------------------------------------
134
# merged: foo@example.com-20060328113140-5749a4757a8ac792
135
# committer: Robert Collins <foo@example.com>
137
# timestamp: Tue 2006-03-28 22:31:40 +1100
140
#------------------------------------------------------------
142
#committer: Robert Collins <foo@example.com>
144
#timestamp: Tue 2006-03-28 22:31:39 +1100
148
# but we dont have a nice pattern matcher hooked up yet, so:
149
# we check for the indenting of the commit message:
150
self.assertTrue(' merge branch 1' in out)
151
self.assertTrue(' merge branch 2' in out)
152
self.assertTrue(' branch 2' in out)
153
self.assertTrue(' branch 1' in out)
154
self.assertTrue(' first post' in out)
155
self.assertEqual('', err)
158
class TestLogEncodings(TestCaseInTempDir):
161
_message = u'Message with \xb5'
163
# Encodings which can encode mu
168
'cp437', # Common windows encoding
169
'cp1251', # Alexander Belchenko's windows encoding
170
'cp1258', # Common windows encoding
172
# Encodings which cannot encode mu
180
TestCaseInTempDir.setUp(self)
181
self.user_encoding = bzrlib.user_encoding
184
bzrlib.user_encoding = self.user_encoding
185
TestCaseInTempDir.tearDown(self)
187
def create_branch(self):
190
open('a', 'wb').write('some stuff\n')
192
bzr('commit', '-m', self._message)
194
def try_encoding(self, encoding, fail=False):
197
self.assertRaises(UnicodeEncodeError,
198
self._mu.encode, encoding)
199
encoded_msg = self._message.encode(encoding, 'replace')
201
encoded_msg = self._message.encode(encoding)
203
old_encoding = bzrlib.user_encoding
204
# This test requires that 'run_bzr' uses the current
205
# bzrlib, because we override user_encoding, and expect
208
bzrlib.user_encoding = 'ascii'
209
# We should be able to handle any encoding
210
out, err = bzr('log', encoding=encoding)
212
# Make sure we wrote mu as we expected it to exist
213
self.assertNotEqual(-1, out.find(encoded_msg))
214
out_unicode = out.decode(encoding)
215
self.assertNotEqual(-1, out_unicode.find(self._message))
217
self.assertNotEqual(-1, out.find('Message with ?'))
219
bzrlib.user_encoding = old_encoding
221
def test_log_handles_encoding(self):
224
for encoding in self.good_encodings:
225
self.try_encoding(encoding)
227
def test_log_handles_bad_encoding(self):
230
for encoding in self.bad_encodings:
231
self.try_encoding(encoding, fail=True)
233
def test_stdout_encoding(self):
235
bzrlib.user_encoding = "cp1251"
238
self.build_tree(['a'])
240
bzr('commit', '-m', u'\u0422\u0435\u0441\u0442')
241
stdout, stderr = self.run_bzr('log', encoding='cp866')
243
message = stdout.splitlines()[-1]
245
# explanation of the check:
246
# u'\u0422\u0435\u0441\u0442' is word 'Test' in russian
247
# in cp866 encoding this is string '\x92\xa5\xe1\xe2'
248
# in cp1251 encoding this is string '\xd2\xe5\xf1\xf2'
249
# This test should check that output of log command
250
# encoded to sys.stdout.encoding
251
test_in_cp866 = '\x92\xa5\xe1\xe2'
252
test_in_cp1251 = '\xd2\xe5\xf1\xf2'
253
# Make sure the log string is encoded in cp866
254
self.assertEquals(test_in_cp866, message[2:])
255
# Make sure the cp1251 string is not found anywhere
256
self.assertEquals(-1, stdout.find(test_in_cp1251))