Show More
@@ -1710,6 +1710,7 b' def _chistedit(ui, repo, freeargs, opts)' | |||
|
1710 | 1710 | ctxs = [] |
|
1711 | 1711 | for i, r in enumerate(revs): |
|
1712 | 1712 | ctxs.append(histeditrule(ui, repo[r], i)) |
|
1713 | with util.with_lc_ctype(): | |
|
1713 | 1714 | rc = curses.wrapper(functools.partial(_chisteditmain, repo, ctxs)) |
|
1714 | 1715 | curses.echo() |
|
1715 | 1716 | curses.endwin() |
@@ -569,6 +569,7 b' def chunkselector(ui, headerlist, operat' | |||
|
569 | 569 | if util.safehasattr(signal, b'SIGTSTP'): |
|
570 | 570 | origsigtstp = signal.getsignal(signal.SIGTSTP) |
|
571 | 571 | try: |
|
572 | with util.with_lc_ctype(): | |
|
572 | 573 | curses.wrapper(chunkselector.main) |
|
573 | 574 | if chunkselector.initexc is not None: |
|
574 | 575 | raise chunkselector.initexc |
@@ -13,7 +13,6 b' from __future__ import absolute_import' | |||
|
13 | 13 | import getopt |
|
14 | 14 | import inspect |
|
15 | 15 | import json |
|
16 | import locale | |
|
17 | 16 | import os |
|
18 | 17 | import shlex |
|
19 | 18 | import sys |
@@ -94,26 +93,6 b' def rapply(f, xs):' | |||
|
94 | 93 | return _rapply(f, xs) |
|
95 | 94 | |
|
96 | 95 | |
|
97 | # Passing the '' locale means that the locale should be set according to the | |
|
98 | # user settings (environment variables). | |
|
99 | # Python sometimes avoids setting the global locale settings. When interfacing | |
|
100 | # with C code (e.g. the curses module or the Subversion bindings), the global | |
|
101 | # locale settings must be initialized correctly. Python 2 does not initialize | |
|
102 | # the global locale settings on interpreter startup. Python 3 sometimes | |
|
103 | # initializes LC_CTYPE, but not consistently at least on Windows. Therefore we | |
|
104 | # explicitly initialize it to get consistent behavior if it's not already | |
|
105 | # initialized. Since CPython commit 177d921c8c03d30daa32994362023f777624b10d, | |
|
106 | # LC_CTYPE is always initialized. If we require Python 3.8+, we should re-check | |
|
107 | # if we can remove this code. | |
|
108 | if locale.setlocale(locale.LC_CTYPE, None) == 'C': | |
|
109 | try: | |
|
110 | locale.setlocale(locale.LC_CTYPE, '') | |
|
111 | except locale.Error: | |
|
112 | # The likely case is that the locale from the environment variables is | |
|
113 | # unknown. | |
|
114 | pass | |
|
115 | ||
|
116 | ||
|
117 | 96 | if ispy3: |
|
118 | 97 | import builtins |
|
119 | 98 | import codecs |
@@ -22,6 +22,7 b' import errno' | |||
|
22 | 22 | import gc |
|
23 | 23 | import hashlib |
|
24 | 24 | import itertools |
|
25 | import locale | |
|
25 | 26 | import mmap |
|
26 | 27 | import os |
|
27 | 28 | import platform as pyplatform |
@@ -3596,3 +3597,32 b' def uvarintdecodestream(fh):' | |||
|
3596 | 3597 | if not (byte & 0x80): |
|
3597 | 3598 | return result |
|
3598 | 3599 | shift += 7 |
|
3600 | ||
|
3601 | ||
|
3602 | # Passing the '' locale means that the locale should be set according to the | |
|
3603 | # user settings (environment variables). | |
|
3604 | # Python sometimes avoids setting the global locale settings. When interfacing | |
|
3605 | # with C code (e.g. the curses module or the Subversion bindings), the global | |
|
3606 | # locale settings must be initialized correctly. Python 2 does not initialize | |
|
3607 | # the global locale settings on interpreter startup. Python 3 sometimes | |
|
3608 | # initializes LC_CTYPE, but not consistently at least on Windows. Therefore we | |
|
3609 | # explicitly initialize it to get consistent behavior if it's not already | |
|
3610 | # initialized. Since CPython commit 177d921c8c03d30daa32994362023f777624b10d, | |
|
3611 | # LC_CTYPE is always initialized. If we require Python 3.8+, we should re-check | |
|
3612 | # if we can remove this code. | |
|
3613 | @contextlib.contextmanager | |
|
3614 | def with_lc_ctype(): | |
|
3615 | oldloc = locale.setlocale(locale.LC_CTYPE, None) | |
|
3616 | if oldloc == 'C': | |
|
3617 | try: | |
|
3618 | try: | |
|
3619 | locale.setlocale(locale.LC_CTYPE, '') | |
|
3620 | except locale.Error: | |
|
3621 | # The likely case is that the locale from the environment | |
|
3622 | # variables is unknown. | |
|
3623 | pass | |
|
3624 | yield | |
|
3625 | finally: | |
|
3626 | locale.setlocale(locale.LC_CTYPE, oldloc) | |
|
3627 | else: | |
|
3628 | yield |
General Comments 0
You need to be logged in to leave comments.
Login now