Comment 1 for bug 5041

Revision history for this message
Ivan Vilata i Balaguer (ivilata) wrote :

I find the following patch to be a simpler solution to the *second* problem. Maybe ``edit_commit_message()`` (and not ``cmd_commit.run()``) is the right place to do the conversion to Unicode, since the editor may leave additional tips on the encoding of the file (like Emacs' ``-*- coding: xxx -*-``). Maybe ``edit_commit_message()`` should also get the ``input_encoding`` option, I don't know.

----

--- msgeditor.py.orig 2005-12-06 13:49:06.645099016 +0100
+++ msgeditor.py 2005-12-06 13:57:15.331807344 +0100
@@ -20,8 +20,10 @@
 """Commit message editor support."""

 import os
+import codecs
 from subprocess import call

+import bzrlib
 import bzrlib.config as config
 from bzrlib.errors import BzrError

@@ -95,7 +97,7 @@
         started = False
         msg = []
         lastline, nlines = 0, 0
- for line in file(msgfilename, "r"):
+ for line in codecs.open(msgfilename, 'rt', bzrlib.user_encoding):
             stripped_line = line.strip()
             # strip empty line before the log message starts
             if not started: