Patchwork [1,of,2] curses: back out d2227d4c9e6b (do not initialize LC_ALL to user settings)

login
register
mail settings
Submitter Manuel Jacob
Date June 28, 2020, 3:54 p.m.
Message ID <b7e0d1cf9aa1d122075e.1593359672@tmp>
Download mbox | patch
Permalink /patch/46587/
State Accepted
Headers show

Comments

Manuel Jacob - June 28, 2020, 3:54 p.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1593359354 -7200
#      Sun Jun 28 17:49:14 2020 +0200
# Node ID b7e0d1cf9aa1d122075eb9100702aa20686fa42b
# Parent  47a07bbf400a24ef48bcaf0e7a4c15365c3a000b
curses: back out d2227d4c9e6b (do not initialize LC_ALL to user settings)

The changeset was based on a25343d16ebe, which will be backed out, too.
Another fix for the problem will be resubmitted to the stable branch.
Yuya Nishihara - June 29, 2020, 11:15 a.m.
On Sun, 28 Jun 2020 17:54:32 +0200, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me@manueljacob.de>
> # Date 1593359354 -7200
> #      Sun Jun 28 17:49:14 2020 +0200
> # Node ID b7e0d1cf9aa1d122075eb9100702aa20686fa42b
> # Parent  47a07bbf400a24ef48bcaf0e7a4c15365c3a000b
> curses: back out d2227d4c9e6b (do not initialize LC_ALL to user settings)

Queued, thanks.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -201,6 +201,7 @@ 
     termios = None
 
 import functools
+import locale
 import os
 import struct
 
@@ -1710,6 +1711,10 @@ 
         ctxs = []
         for i, r in enumerate(revs):
             ctxs.append(histeditrule(ui, repo[r], i))
+        # Curses requires setting the locale or it will default to the C
+        # locale. This sets the locale to the user's default system
+        # locale.
+        locale.setlocale(locale.LC_ALL, '')
         rc = curses.wrapper(functools.partial(_chisteditmain, repo, ctxs))
         curses.echo()
         curses.endwin()
diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -10,6 +10,7 @@ 
 
 from __future__ import absolute_import
 
+import locale
 import os
 import re
 import signal
@@ -565,6 +566,9 @@ 
     """
     ui.write(_(b'starting interactive selection\n'))
     chunkselector = curseschunkselector(headerlist, ui, operation)
+    # This is required for ncurses to display non-ASCII characters in
+    # default user locale encoding correctly.  --immerrr
+    locale.setlocale(locale.LC_ALL, '')
     origsigtstp = sentinel = object()
     if util.safehasattr(signal, b'SIGTSTP'):
         origsigtstp = signal.getsignal(signal.SIGTSTP)