Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 31347:a9a28ca17615
util: pass encoding.[encoding|encodingmode] as unicodes
We need to pass str to encode() and decode().
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 12 Mar 2017 07:35:13 +0530 |
parents | 78ac7061f840 |
children | 6e59397b08d8 |
comparison
equal
deleted
inserted
replaced
31346:ec7831675867 | 31347:a9a28ca17615 |
---|---|
2239 def wrap(line, width, initindent='', hangindent=''): | 2239 def wrap(line, width, initindent='', hangindent=''): |
2240 maxindent = max(len(hangindent), len(initindent)) | 2240 maxindent = max(len(hangindent), len(initindent)) |
2241 if width <= maxindent: | 2241 if width <= maxindent: |
2242 # adjust for weird terminal size | 2242 # adjust for weird terminal size |
2243 width = max(78, maxindent + 1) | 2243 width = max(78, maxindent + 1) |
2244 line = line.decode(encoding.encoding, encoding.encodingmode) | 2244 line = line.decode(pycompat.sysstr(encoding.encoding), |
2245 initindent = initindent.decode(encoding.encoding, encoding.encodingmode) | 2245 pycompat.sysstr(encoding.encodingmode)) |
2246 hangindent = hangindent.decode(encoding.encoding, encoding.encodingmode) | 2246 initindent = initindent.decode(pycompat.sysstr(encoding.encoding), |
2247 pycompat.sysstr(encoding.encodingmode)) | |
2248 hangindent = hangindent.decode(pycompat.sysstr(encoding.encoding), | |
2249 pycompat.sysstr(encoding.encodingmode)) | |
2247 wrapper = MBTextWrapper(width=width, | 2250 wrapper = MBTextWrapper(width=width, |
2248 initial_indent=initindent, | 2251 initial_indent=initindent, |
2249 subsequent_indent=hangindent) | 2252 subsequent_indent=hangindent) |
2250 return wrapper.fill(line).encode(encoding.encoding) | 2253 return wrapper.fill(line).encode(pycompat.sysstr(encoding.encoding)) |
2251 | 2254 |
2252 if (pyplatform.python_implementation() == 'CPython' and | 2255 if (pyplatform.python_implementation() == 'CPython' and |
2253 sys.version_info < (3, 0)): | 2256 sys.version_info < (3, 0)): |
2254 # There is an issue in CPython that some IO methods do not handle EINTR | 2257 # There is an issue in CPython that some IO methods do not handle EINTR |
2255 # correctly. The following table shows what CPython version (and functions) | 2258 # correctly. The following table shows what CPython version (and functions) |