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

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

Comments

Sean Farley - Dec. 16, 2015, 6:46 p.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 35383e197db82c661b8db7be70297e96cab0839a
# Parent  9cc732d13ec2938638a80be90c4deac0ca52dbb2
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
@@ -51,10 +51,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)