diff -r 08914fd0fddb -r 02c43e8e0835 mercurial/util.py --- a/mercurial/util.py Tue Sep 29 00:54:15 2009 +0200 +++ b/mercurial/util.py Wed Sep 30 21:14:24 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 @@ -1278,7 +1278,14 @@ # adjust for weird terminal size width = max(78, hangindent + 1) 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. + try: + u = line.decode(encoding.encoding) + w = padding.join(textwrap.wrap(u, width=width - hangindent)) + return w.encode(encoding.encoding) + except UnicodeDecodeError: + return padding.join(textwrap.wrap(line, width=width - hangindent)) def iterlines(iterator): for chunk in iterator: