--- a/mercurial/util.py Wed Sep 23 18:56:09 2009 +0200
+++ b/mercurial/util.py Sun Sep 27 01:44:46 2009 +0200
@@ -14,7 +14,7 @@
"""
from i18n import _
-import error, osutil
+import error, osutil, encoding
import cStringIO, errno, re, shutil, sys, tempfile, traceback
import os, stat, time, calendar, random, textwrap
import imp
@@ -1276,7 +1276,11 @@
def wrap(line, hangindent, width=78):
padding = '\n' + ' ' * hangindent
- return padding.join(textwrap.wrap(line, width=width - hangindent))
+ # To avoid corrupting multi-byte characters in line, we must wrap
+ # a Unicode string instead of a bytestring.
+ u = line.decode(encoding.encoding)
+ w = padding.join(textwrap.wrap(u, width=width - hangindent))
+ return w.encode(encoding.encoding)
def iterlines(iterator):
for chunk in iterator: