Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 9508:e2fd9b62349b
Merge with -stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 30 Sep 2009 21:42:51 -0500 |
parents | ca3390c19f88 b2d65ee49a72 |
children | 4368f582c806 |
comparison
equal
deleted
inserted
replaced
9494:bdd8a41ea6f6 | 9508:e2fd9b62349b |
---|---|
1278 # adjust for weird terminal size | 1278 # adjust for weird terminal size |
1279 width = max(78, hangindent + 1) | 1279 width = max(78, hangindent + 1) |
1280 padding = '\n' + ' ' * hangindent | 1280 padding = '\n' + ' ' * hangindent |
1281 # To avoid corrupting multi-byte characters in line, we must wrap | 1281 # To avoid corrupting multi-byte characters in line, we must wrap |
1282 # a Unicode string instead of a bytestring. | 1282 # a Unicode string instead of a bytestring. |
1283 u = line.decode(encoding.encoding) | 1283 try: |
1284 w = padding.join(textwrap.wrap(u, width=width - hangindent)) | 1284 u = line.decode(encoding.encoding) |
1285 return w.encode(encoding.encoding) | 1285 w = padding.join(textwrap.wrap(u, width=width - hangindent)) |
1286 return w.encode(encoding.encoding) | |
1287 except UnicodeDecodeError: | |
1288 return padding.join(textwrap.wrap(line, width=width - hangindent)) | |
1286 | 1289 |
1287 def iterlines(iterator): | 1290 def iterlines(iterator): |
1288 for chunk in iterator: | 1291 for chunk in iterator: |
1289 for line in chunk.splitlines(): | 1292 for line in chunk.splitlines(): |
1290 yield line | 1293 yield line |