Patchwork [5,of,5,stable,V2] crecord: stop raising error.Abort if curses is not found (issue5008)

login
register
mail settings
Submitter Sean Farley
Date Dec. 16, 2015, 6:46 p.m.
Message ID <5da9a32c1681a68e8a51.1450291587@laptop.office.atlassian.com>
Download mbox | patch
Permalink /patch/12079/
State Accepted
Headers show

Comments

Sean Farley - Dec. 16, 2015, 6:46 p.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1450291140 28800
#      Wed Dec 16 10:39:00 2015 -0800
# Branch stable
# Node ID 5da9a32c1681a68e8a5115852586e04ac780f1f4
# Parent  dc4c30b212b79a63a43930ef6547e4165fb810e3
crecord: stop raising error.Abort if curses is not found (issue5008)

On some servers, python curses support is disabled. This patch not only fixes
that but provides a fallback on other machines (e.g. Windows) when curses is
not found.

The previous code was actually flawed logic and relied on wcurses throwing an
ImportError which demandimport wouldn't throw. So, this patch also fixes that
problem.
Augie Fackler - Dec. 18, 2015, 5:55 p.m.
On Wed, Dec 16, 2015 at 10:46:27AM -0800, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean@farley.io>
> # Date 1450291140 28800
> #      Wed Dec 16 10:39:00 2015 -0800
> # Branch stable
> # Node ID 5da9a32c1681a68e8a5115852586e04ac780f1f4
> # Parent  dc4c30b212b79a63a43930ef6547e4165fb810e3
> crecord: stop raising error.Abort if curses is not found (issue5008)

This strikes me as the upper end of reasonable for stable, but I'm
taking it because it's not uncommon to leave curses off of servers. Queued.

>
> On some servers, python curses support is disabled. This patch not only fixes
> that but provides a fallback on other machines (e.g. Windows) when curses is
> not found.
>
> The previous code was actually flawed logic and relied on wcurses throwing an
> ImportError which demandimport wouldn't throw. So, this patch also fixes that
> problem.
>
> diff --git a/mercurial/crecord.py b/mercurial/crecord.py
> --- a/mercurial/crecord.py
> +++ b/mercurial/crecord.py
> @@ -45,17 +45,10 @@ except ImportError:
>      except ImportError:
>          # wcurses is not shipped on Windows by default, or python is not
>          # compiled with curses
>          curses = False
>
> -try:
> -    curses
> -except NameError:
> -    if os.name != 'nt':  # Temporary hack to get running on Windows again
> -        raise error.Abort(
> -            _('the python curses/wcurses module is not available/installed'))
> -
>  def checkcurses(ui):
>      """Return True if the user wants to use curses
>
>      This method returns True if curses is found (and that python is built with
>      it) and that the user has the correct flag for the ui.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -45,17 +45,10 @@  except ImportError:
     except ImportError:
         # wcurses is not shipped on Windows by default, or python is not
         # compiled with curses
         curses = False
 
-try:
-    curses
-except NameError:
-    if os.name != 'nt':  # Temporary hack to get running on Windows again
-        raise error.Abort(
-            _('the python curses/wcurses module is not available/installed'))
-
 def checkcurses(ui):
     """Return True if the user wants to use curses
 
     This method returns True if curses is found (and that python is built with
     it) and that the user has the correct flag for the ui.