Rev 5214: better unicode handling when commit message (-m) is same as unicode in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed May 5 19:51:21 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5214 [merge]
revision-id: pqm at pqm.ubuntu.com-20100505185116-yheyjpt123oq3wm2
parent: pqm at pqm.ubuntu.com-20100505173116-peb5afaw8y7b9i2o
parent: parth.malwankar at gmail.com-20100505160046-o07b82avu84xj0jg
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2010-05-05 19:51:16 +0100
message:
better unicode handling when commit message (-m) is same as unicode
filename. (parthm, #563646)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
=== modified file 'NEWS'
--- a/NEWS 2010-05-05 17:31:16 +0000
+++ b/NEWS 2010-05-05 18:51:16 +0000
@@ -96,6 +96,11 @@
* Unicode characters in aliases are now handled correctly and do not cause
UnicodeEncodeError exception. (Parth Malwankar, #529930)
+* Unicode commit messages that are the same as a file name no longer cause
+ UnicodeEncodeError. ``ui.text.show_warning`` now handles unicode
+ messages.
+ (Parth Malwankar, #563646)
+
Improvements
************
=== modified file 'bzrlib/tests/blackbox/test_commit.py'
--- a/bzrlib/tests/blackbox/test_commit.py 2010-04-27 17:09:48 +0000
+++ b/bzrlib/tests/blackbox/test_commit.py 2010-05-05 18:51:16 +0000
@@ -18,6 +18,7 @@
"""Tests for the commit CLI of bzr."""
import os
+import re
import sys
from bzrlib import (
@@ -107,6 +108,40 @@
'modified hello\.txt\n'
'Committed revision 2\.\n$')
+ def test_unicode_commit_message_is_filename(self):
+ """Unicode commit message same as a filename (Bug #563646).
+ """
+ file_name = u'\N{euro sign}'
+ self.run_bzr(['init'])
+ open(file_name, 'w').write('hello world')
+ self.run_bzr(['add'])
+ out, err = self.run_bzr(['commit', '-m', file_name])
+ reflags = re.MULTILINE|re.DOTALL|re.UNICODE
+ te = osutils.get_terminal_encoding()
+ self.assertContainsRe(err.decode(te),
+ u'The commit message is a file name:',
+ flags=reflags)
+
+ # Run same test with a filename that causes encode
+ # error for the terminal encoding. We do this
+ # by forcing terminal encoding of ascii for
+ # osutils.get_terminal_encoding which is used
+ # by ui.text.show_warning
+ default_get_terminal_enc = osutils.get_terminal_encoding
+ try:
+ osutils.get_terminal_encoding = lambda: 'ascii'
+ file_name = u'foo\u1234'
+ open(file_name, 'w').write('hello world')
+ self.run_bzr(['add'])
+ out, err = self.run_bzr(['commit', '-m', file_name])
+ reflags = re.MULTILINE|re.DOTALL|re.UNICODE
+ te = osutils.get_terminal_encoding()
+ self.assertContainsRe(err.decode(te, 'replace'),
+ u'The commit message is a file name:',
+ flags=reflags)
+ finally:
+ osutils.get_terminal_encoding = default_get_terminal_enc
+
def test_warn_about_forgotten_commit_message(self):
"""Test that the lack of -m parameter is caught"""
wt = self.make_branch_and_tree('.')
=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py 2010-03-25 07:34:15 +0000
+++ b/bzrlib/ui/text.py 2010-04-22 16:04:16 +0000
@@ -233,6 +233,9 @@
def show_warning(self, msg):
self.clear_term()
+ if isinstance(msg, unicode):
+ te = osutils.get_terminal_encoding()
+ msg = msg.encode(te, 'replace')
self.stderr.write("bzr: warning: %s\n" % msg)
def _progress_updated(self, task):
More information about the bazaar-commits
mailing list