diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c --- a/contrib/chg/chg.c +++ b/contrib/chg/chg.c @@ -227,6 +227,8 @@ static void execcmdserver(const struct c memcpy(argv + baseargvsize, opts->args, sizeof(char *) * opts->argsize); argv[argsize - 1] = NULL; + if (putenv("CHGINTERNALMARK=") != 0) + abortmsg("failed to putenv (errno = %d)", errno); if (execvp(hgcmd, (char **)argv) < 0) abortmsg("failed to exec cmdserver (errno = %d)", errno); free(argv); @@ -490,6 +492,12 @@ int main(int argc, const char *argv[], c if (getenv("CHGDEBUG")) enabledebugmsg(); + if (getenv("CHGINTERNALMARK")) + 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."); + if (isunsupported(argc - 1, argv + 1)) execoriginalhg(argv); diff --git a/hgext/chgserver.py b/hgext/chgserver.py --- a/hgext/chgserver.py +++ b/hgext/chgserver.py @@ -472,3 +472,8 @@ class chgunixservice(commandserver.unixs def uisetup(ui): commandserver._servicemap['chgunix'] = chgunixservice + + # CHGINTERNALMARK is temporarily set by chg client to detect if chg will + # start another chg. drop it to avoid possible side effects. + if 'CHGINTERNALMARK' in os.environ: + del os.environ['CHGINTERNALMARK']