contrib/chg/chg.c
changeset 28358 ffd3ac07b1d7
parent 28357 2f0f352d4196
child 28453 8a7110e351ec
equal deleted inserted replaced
28357:2f0f352d4196 28358:ffd3ac07b1d7
   547 			return 0;
   547 			return 0;
   548 		}
   548 		}
   549 	}
   549 	}
   550 
   550 
   551 	hgclient_t *hgc;
   551 	hgclient_t *hgc;
       
   552 	size_t retry = 0;
   552 	while (1) {
   553 	while (1) {
   553 		hgc = connectcmdserver(&opts);
   554 		hgc = connectcmdserver(&opts);
   554 		if (!hgc)
   555 		if (!hgc)
   555 			abortmsg("cannot open hg client");
   556 			abortmsg("cannot open hg client");
   556 		hgc_setenv(hgc, envp);
   557 		hgc_setenv(hgc, envp);
   558 		if (insts == NULL)
   559 		if (insts == NULL)
   559 			break;
   560 			break;
   560 		runinstructions(&opts, insts);
   561 		runinstructions(&opts, insts);
   561 		free(insts);
   562 		free(insts);
   562 		hgc_close(hgc);
   563 		hgc_close(hgc);
       
   564 		if (++retry > 10)
       
   565 			abortmsg("too many redirections.\n"
       
   566 				 "Please make sure %s is not a wrapper which "
       
   567 				 "changes sensitive environment variables "
       
   568 				 "before executing hg. If you have to use a "
       
   569 				 "wrapper, wrap chg instead of hg.",
       
   570 				 gethgcmd());
   563 	}
   571 	}
   564 
   572 
   565 	setupsignalhandler(hgc_peerpid(hgc));
   573 	setupsignalhandler(hgc_peerpid(hgc));
   566 	setuppager(hgc, argv + 1, argc - 1);
   574 	setuppager(hgc, argv + 1, argc - 1);
   567 	int exitcode = hgc_runcommand(hgc, argv + 1, argc - 1);
   575 	int exitcode = hgc_runcommand(hgc, argv + 1, argc - 1);