[PATCH 3 of 3 V4] chg: limit reconnect attempts
Jun Wu
quark at fb.com
Sun Mar 6 08:16:18 EST 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1456915378 0
# Wed Mar 02 10:42:58 2016 +0000
# Node ID cba41d9ea3cfac81eb124b2556d6ee56f9e17737
# Parent 29fb9d1f0ace0f4a96469d95fac6af081189185f
chg: limit reconnect attempts
Some users may have hg as a wrapper script which sets sensitive environment
variables (like setting up virtualenv). This will make chg redirect forever
because the environment variables are never considered up to date.
This patch adds a limit (10) for reconnect attempts and warn the user with
a possible solution if the limit is exceeded.
diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -549,6 +549,7 @@
}
hgclient_t *hgc;
+ size_t retry = 0;
while (1) {
hgc = connectcmdserver(&opts);
if (!hgc)
@@ -559,6 +560,13 @@
break;
runinstructions(&opts, insts);
hgc_close(hgc);
+ if (++retry > 10)
+ abortmsg("too many redirections.\n"
+ "Please make sure %s is not a wrapper which "
+ "changes sensitive environment variables "
+ "before executing hg. If you have to use a "
+ "wrapper, wrap chg instead of hg.",
+ gethgcmd());
}
setupsignalhandler(hgc_peerpid(hgc));
More information about the Mercurial-devel
mailing list