From patchwork Wed Feb 24 14:31:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,3] chg: detect chg started by chg From: Jun Wu X-Patchwork-Id: 13353 Message-Id: <2c07d50c16da4f859b3c.1456324285@x1c> To: Date: Wed, 24 Feb 2016 14:31:25 +0000 # HG changeset patch # User Jun Wu # Date 1456324196 0 # Wed Feb 24 14:29:56 2016 +0000 # Node ID 2c07d50c16da4f859b3cb002d9c5a04554b7478f # Parent b7c36ebb96f5492f3dd90bacbb8fee65c6eabb59 chg: detect chg started by chg Sometimes people may create a symbol link from hg to chg, or write a wrapper script named hg calling chg. Without $HG and $CHGHG set, this will lead to chg executes itself causing deadlock. The user will notice chg hangs for some time and aborts with a timed out message, without knowing the root cause and how to solve it. This patch sets a dummy environment variable CHGMARK to detect this situation, and print a fatal message with some possible solutions. diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c --- a/contrib/chg/chg.c +++ b/contrib/chg/chg.c @@ -479,6 +479,13 @@ if (getenv("CHGDEBUG")) enabledebugmsg(); + if (getenv("CHGMARK")) + abortmsg("chg started by chg detected.\n" + "Please make sure ${HG:-hg} is not a symlink or " + "wrapper to chg. Alternatively, set $CHGHG to the " + "path of real hg."); + setenv("CHGMARK", "", 1); + if (isunsupported(argc, argv)) execoriginalhg(argv);