[PATCH] chistedit: ensure a locale is set

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] chistedit: ensure a locale is set

Jordi Gutiérrez Hermoso
# HG changeset patch
# User Jordi Gutiérrez Hermoso <[hidden email]>
# Date 1550260567 18000
#      Fri Feb 15 14:56:07 2019 -0500
# Node ID 611f94479e62c720f7f90f3a58137e97aa600fcb
# Parent  a22321f2b1ee18ea09a70fee9e524d2f0298aaaa
chistedit: ensure a locale is set

My paternal surname was showing incorrectly without this fix.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -948,6 +948,12 @@ def findoutgoing(ui, repo, remote=None,
 # Curses Support
 try:
     import curses
+
+    # Curses requires setting the locale or it will default to the C
+    # locale. This sets the locale to the user's default system
+    # locale.
+    import locale
+    locale.setlocale(locale.LC_ALL, u'')
 except ImportError:
     curses = None
 
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] chistedit: ensure a locale is set

Augie Fackler-2
On Fri, Feb 15, 2019 at 02:59:37PM -0500, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <[hidden email]>
> # Date 1550260567 18000
> #      Fri Feb 15 14:56:07 2019 -0500
> # Node ID 611f94479e62c720f7f90f3a58137e97aa600fcb
> # Parent  a22321f2b1ee18ea09a70fee9e524d2f0298aaaa
> chistedit: ensure a locale is set

uhhhh, if you say so

queued

>
> My paternal surname was showing incorrectly without this fix.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -948,6 +948,12 @@ def findoutgoing(ui, repo, remote=None,
>  # Curses Support
>  try:
>      import curses
> +
> +    # Curses requires setting the locale or it will default to the C
> +    # locale. This sets the locale to the user's default system
> +    # locale.
> +    import locale
> +    locale.setlocale(locale.LC_ALL, u'')
>  except ImportError:
>      curses = None
>
> _______________________________________________
> Mercurial-devel mailing list
> [hidden email]
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] chistedit: ensure a locale is set

Jordi Gutiérrez Hermoso
On Tue, 2019-02-19 at 10:29 -0500, Augie Fackler wrote:

> On Fri, Feb 15, 2019 at 02:59:37PM -0500, Jordi Gutiérrez Hermoso wrote:
> > # HG changeset patch
> > # User Jordi Gutiérrez Hermoso <[hidden email]>
> > # Date 1550260567 18000
> > #      Fri Feb 15 14:56:07 2019 -0500
> > # Node ID 611f94479e62c720f7f90f3a58137e97aa600fcb
> > # Parent  a22321f2b1ee18ea09a70fee9e524d2f0298aaaa
> > chistedit: ensure a locale is set
>
> uhhhh, if you say so
>
> queued

If it's any reassurance, crecord does this too, and you haven't seen
weirndess when picking hunks, have you?

_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] chistedit: ensure a locale is set

Augie Fackler-2


> On Feb 19, 2019, at 10:33, Jordi Gutiérrez Hermoso <[hidden email]> wrote:
>
> On Tue, 2019-02-19 at 10:29 -0500, Augie Fackler wrote:
>> On Fri, Feb 15, 2019 at 02:59:37PM -0500, Jordi Gutiérrez Hermoso wrote:
>>> # HG changeset patch
>>> # User Jordi Gutiérrez Hermoso <[hidden email]>
>>> # Date 1550260567 18000
>>> #      Fri Feb 15 14:56:07 2019 -0500
>>> # Node ID 611f94479e62c720f7f90f3a58137e97aa600fcb
>>> # Parent  a22321f2b1ee18ea09a70fee9e524d2f0298aaaa
>>> chistedit: ensure a locale is set
>>
>> uhhhh, if you say so
>>
>> queued
>
> If it's any reassurance, crecord does this too, and you haven't seen
> weirndess when picking hunks, have you?

I live a 7-bit-clean lifestyle. ;)
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] chistedit: ensure a locale is set

Yuya Nishihara
In reply to this post by Jordi Gutiérrez Hermoso
On Fri, 15 Feb 2019 14:59:37 -0500, Jordi Gutiérrez Hermoso wrote:

> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <[hidden email]>
> # Date 1550260567 18000
> #      Fri Feb 15 14:56:07 2019 -0500
> # Node ID 611f94479e62c720f7f90f3a58137e97aa600fcb
> # Parent  a22321f2b1ee18ea09a70fee9e524d2f0298aaaa
> chistedit: ensure a locale is set
>
> My paternal surname was showing incorrectly without this fix.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -948,6 +948,12 @@ def findoutgoing(ui, repo, remote=None,
>  # Curses Support
>  try:
>      import curses
> +
> +    # Curses requires setting the locale or it will default to the C
> +    # locale. This sets the locale to the user's default system
> +    # locale.
> +    import locale
> +    locale.setlocale(locale.LC_ALL, u'')

Just FYI, this will make the issue5261 more likely happen since extension
modules aren't demand-loaded.

https://bz.mercurial-scm.org/show_bug.cgi?id=5261

Perhaps, we shouldn't do setlocale() until curses is actually used.
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] chistedit: ensure a locale is set

Jordi Gutiérrez Hermoso
On Wed, 2019-02-20 at 11:22 +0900, Yuya Nishihara wrote:
> Perhaps, we shouldn't do setlocale() until curses is actually used.

Hm, that's a good point. Move it to _chisteditmain? That's the entry
point, I think.

Or maybe we should make our own wrapper curses module so it can be
demandimported and use that from both chistedit and crecord?

_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] chistedit: ensure a locale is set

Yuya Nishihara
On Tue, 19 Feb 2019 23:16:03 -0500, Jordi Gutiérrez Hermoso wrote:
> On Wed, 2019-02-20 at 11:22 +0900, Yuya Nishihara wrote:
> > Perhaps, we shouldn't do setlocale() until curses is actually used.
>
> Hm, that's a good point. Move it to _chisteditmain? That's the entry
> point, I think.
>
> Or maybe we should make our own wrapper curses module so it can be
> demandimported and use that from both chistedit and crecord?

Maybe we can add a curses setup function that calls setlocale().
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel