Mercurial > hg
comparison hgext/histedit.py @ 45011:1bab6b61b62b stable
curses: do not initialize LC_ALL to user settings (issue6358)
701341f57ceb moved the setlocale() call to right before curses was used. This
didn’t fully solve the problem it was supposed to solve (locale-dependent
functions, like date formatting/parsing and str methods on Python 2), but only
postponed it.
Initializing LC_CTYPE seems to be sufficient for curses to work correctly.
Therefore LC_CTYPE is set while curses is used and reset afterwards. Some
locale-dependent str methods might behave differently on Python 2 while curses
is used, but that shouldn’d be a problem.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sun, 28 Jun 2020 18:02:45 +0200 |
parents | e147748f750b |
children | 4a503c1b664a |
comparison
equal
deleted
inserted
replaced
45004:2632c1ed8f34 | 45011:1bab6b61b62b |
---|---|
199 except ImportError: | 199 except ImportError: |
200 fcntl = None | 200 fcntl = None |
201 termios = None | 201 termios = None |
202 | 202 |
203 import functools | 203 import functools |
204 import locale | |
205 import os | 204 import os |
206 import struct | 205 import struct |
207 | 206 |
208 from mercurial.i18n import _ | 207 from mercurial.i18n import _ |
209 from mercurial.pycompat import ( | 208 from mercurial.pycompat import ( |
1708 ) | 1707 ) |
1709 | 1708 |
1710 ctxs = [] | 1709 ctxs = [] |
1711 for i, r in enumerate(revs): | 1710 for i, r in enumerate(revs): |
1712 ctxs.append(histeditrule(ui, repo[r], i)) | 1711 ctxs.append(histeditrule(ui, repo[r], i)) |
1713 # Curses requires setting the locale or it will default to the C | 1712 with util.with_lc_ctype(): |
1714 # locale. This sets the locale to the user's default system | 1713 rc = curses.wrapper(functools.partial(_chisteditmain, repo, ctxs)) |
1715 # locale. | |
1716 locale.setlocale(locale.LC_ALL, '') | |
1717 rc = curses.wrapper(functools.partial(_chisteditmain, repo, ctxs)) | |
1718 curses.echo() | 1714 curses.echo() |
1719 curses.endwin() | 1715 curses.endwin() |
1720 if rc is False: | 1716 if rc is False: |
1721 ui.write(_(b"histedit aborted\n")) | 1717 ui.write(_(b"histedit aborted\n")) |
1722 return 0 | 1718 return 0 |