Rev 4128: (bialix) Fixed problem with `log -p` and non-ascii content of files in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Mar 12 08:38:18 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4128
revision-id: pqm at pqm.ubuntu.com-20090312083815-gngp4va6p39wr31o
parent: pqm at pqm.ubuntu.com-20090312075222-g575i2pcrliafetw
parent: james.westby at canonical.com-20090312071220-4jy068t5l1kvk776
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-03-12 08:38:15 +0000
message:
(bialix) Fixed problem with `log -p` and non-ascii content of files
modified:
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
------------------------------------------------------------
revno: 4108.1.4
revision-id: james.westby at canonical.com-20090312071220-4jy068t5l1kvk776
parent: james.westby at canonical.com-20090312030359-ishfh5p46t2isl1n
parent: bialix at ukr.net-20090311085817-ohdgobxgnat17xll
committer: James Westby <james.westby at canonical.com>
branch nick: jamesw-integration
timestamp: Thu 2009-03-12 17:12:20 +1000
message:
Fixed problem with `log -p` and non-ascii content of files
modified:
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
------------------------------------------------------------
revno: 4110.1.1
revision-id: bialix at ukr.net-20090311085817-ohdgobxgnat17xll
parent: pqm at pqm.ubuntu.com-20090311015637-v73ocbv9bcexe4dm
committer: Alexander Belchenko <bialix at ukr.net>
branch nick: log-p
timestamp: Wed 2009-03-11 10:58:17 +0200
message:
Fixed problem with `log -p` and non-ascii content of files: show_diff should write the diff to exact [stdout] stream.
modified:
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py 2009-03-05 02:15:46 +0000
+++ b/bzrlib/log.py 2009-03-11 08:58:17 +0000
@@ -1143,6 +1143,9 @@
let the log formatter decide.
"""
self.to_file = to_file
+ # 'exact' stream used to show diff, it should print content 'as is'
+ # and should not try to decode/encode it to unicode to avoid bug #328007
+ self.to_exact_file = getattr(to_file, 'stream', to_file)
self.show_ids = show_ids
self.show_timezone = show_timezone
if delta_format is None:
@@ -1246,7 +1249,7 @@
to_file.write(indent + 'diff:\n')
# Note: we explicitly don't indent the diff (relative to the
# revision information) so that the output can be fed to patch -p0
- self.show_diff(to_file, revision.diff, indent)
+ self.show_diff(self.to_exact_file, revision.diff, indent)
class ShortLogFormatter(LogFormatter):
@@ -1310,7 +1313,7 @@
revision.delta.show(to_file, self.show_ids, indent=indent + offset,
short_status=self.delta_format==1)
if revision.diff is not None:
- self.show_diff(to_file, revision.diff, ' ')
+ self.show_diff(self.to_exact_file, revision.diff, ' ')
to_file.write('\n')
=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- a/bzrlib/tests/blackbox/test_log.py 2009-02-23 15:42:47 +0000
+++ b/bzrlib/tests/blackbox/test_log.py 2009-03-11 08:58:17 +0000
@@ -659,6 +659,26 @@
""")
+ def test_log_show_diff_non_ascii(self):
+ # Smoke test for bug #328007 UnicodeDecodeError on 'log -p'
+ message = u'Message with \xb5'
+ body = 'Body with \xb5\n'
+ wt = self.make_branch_and_tree('.')
+ self.build_tree_contents([('foo', body)])
+ wt.add('foo')
+ wt.commit(message=message)
+ # check that command won't fail with unicode error
+ # don't care about exact output because we have other tests for this
+ out,err = self.run_bzr('log -p --long')
+ self.assertNotEqual('', out)
+ self.assertEqual('', err)
+ out,err = self.run_bzr('log -p --short')
+ self.assertNotEqual('', out)
+ self.assertEqual('', err)
+ out,err = self.run_bzr('log -p --line')
+ self.assertNotEqual('', out)
+ self.assertEqual('', err)
+
class TestLogEncodings(TestCaseInTempDir):
@@ -671,7 +691,7 @@
'latin-1',
'iso-8859-1',
'cp437', # Common windows encoding
- 'cp1251', # Alexander Belchenko's windows encoding
+ 'cp1251', # Russian windows encoding
'cp1258', # Common windows encoding
]
# Encodings which cannot encode mu
More information about the bazaar-commits
mailing list