Patchwork [2,of,5,stable] crecord: add helper function to determine if we should use curses

login
register
mail settings
Submitter Sean Farley
Date Dec. 16, 2015, 12:06 a.m.
Message ID <eb3ae2a5d034e0b4598b.1450224373@laptop.office.atlassian.com>
Download mbox | patch
Permalink /patch/12061/
State Superseded
Commit 940cedaee9886036d9335cf7fe2c9d33bfda5db8
Delegated to: Laurent Charignon
Headers show

Comments

Sean Farley - Dec. 16, 2015, 12:06 a.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1450223770 28800
#      Tue Dec 15 15:56:10 2015 -0800
# Branch stable
# Node ID eb3ae2a5d034e0b4598bdb824e8584c983998820
# Parent  7ceba88969e51bb825748f69b45e4677e0a02815
crecord: add helper function to determine if we should use curses

To fix issue5008 properly, we need a helper function to determine if curses is
imported and also if the user has enabled the experimental flag.

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -47,10 +47,18 @@  try:
 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.
+    """
+    return curses and ui.configbool('experimental', 'crecord', False)
+
 _origstdout = sys.__stdout__ # used by gethw()
 
 class patchnode(object):
     """abstract class for patch graph nodes
     (i.e. patchroot, header, hunk, hunkline)