From 507ebeeb589210e9ae64212f990bb2e9fba4fb45 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Wed, 6 Jun 2018 12:04:52 -0400 Subject: [PATCH] threadable false --- news/hgi.rst | 14 ++++++++++++++ xonsh/commands_cache.py | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 news/hgi.rst diff --git a/news/hgi.rst b/news/hgi.rst new file mode 100644 index 000000000..17005a90e --- /dev/null +++ b/news/hgi.rst @@ -0,0 +1,14 @@ +**Added:** None + +**Changed:** + +* Mercurial (``hg``) will no longer run in a threadable subprocess when + it is run in interactive mode. + +**Deprecated:** None + +**Removed:** None + +**Fixed:** None + +**Security:** None diff --git a/xonsh/commands_cache.py b/xonsh/commands_cache.py index 1f3505939..b2f77f9e9 100644 --- a/xonsh/commands_cache.py +++ b/xonsh/commands_cache.py @@ -332,6 +332,23 @@ def predict_help_ver(args): return pred +@lazyobject +def HG_PREDICTOR_PARSER(): + p = argparse.ArgumentParser('hg', add_help=False) + p.add_argument('command') + p.add_argument('-i', '--interactive', action='store_true', default=False, + dest='interactive') + return p + + +def predict_hg(args): + """Predict if mercurial is about to be run in interactive mode. + If it is interactive, predict False. If it isn't, predict True. + """ + ns, _ = HG_PREDICTOR_PARSER.parse_known_args(args) + return not ns.interactive + + def default_threadable_predictors(): """Generates a new defaultdict for known threadable predictors. The default is to predict true. @@ -348,6 +365,7 @@ def default_threadable_predictors(): 'emacsclient': predict_false, 'fish': predict_shell, 'gvim': predict_help_ver, + 'hg': predict_hg, 'htop': predict_help_ver, 'ipython': predict_shell, 'ksh': predict_shell,