Show More
@@ -234,18 +234,12 b' static const char *gethgcmd(void)' | |||
|
234 | 234 | hgcmd = "hg"; |
|
235 | 235 | #endif |
|
236 | 236 | } |
|
237 | /* Set $CHGHG to the path to the seleted hg executable if it wasn't | |
|
238 | * already set. This has the effect of ensuring that a new command | |
|
239 | * server will be spawned if the existing command server is running from | |
|
240 | * an executable at a different path. */ | |
|
241 | if (setenv("CHGHG", hgcmd, 1) != 0) | |
|
242 | abortmsgerrno("failed to setenv"); | |
|
243 | 237 | return hgcmd; |
|
244 | 238 | } |
|
245 | 239 | |
|
246 |
static void execcmdserver( |
|
|
240 | static void execcmdserver(const struct cmdserveropts *opts) | |
|
247 | 241 | { |
|
248 | ||
|
242 | const char *hgcmd = gethgcmd(); | |
|
249 | 243 | const char *baseargv[] = { |
|
250 | 244 | hgcmd, "serve", "--no-profile", "--cmdserver", |
|
251 | 245 | "chgunix", "--address", opts->initsockname, "--daemon-postexec", |
@@ -382,16 +376,11 b' static hgclient_t *connectcmdserver(stru' | |||
|
382 | 376 | |
|
383 | 377 | debugmsg("start cmdserver at %s", opts->initsockname); |
|
384 | 378 | |
|
385 | /* Get the path to the hg executable before we fork because this | |
|
386 | * function might update the environment, and we want this to be | |
|
387 | * reflected in both the parent and child processes. */ | |
|
388 | const char *hgcmd = gethgcmd(); | |
|
389 | ||
|
390 | 379 | pid_t pid = fork(); |
|
391 | 380 | if (pid < 0) |
|
392 | 381 | abortmsg("failed to fork cmdserver process"); |
|
393 | 382 | if (pid == 0) { |
|
394 |
execcmdserver( |
|
|
383 | execcmdserver(opts); | |
|
395 | 384 | } else { |
|
396 | 385 | hgc = retryconnectcmdserver(opts, pid); |
|
397 | 386 | } |
@@ -525,6 +514,16 b' int main(int argc, const char *argv[])' | |||
|
525 | 514 | } |
|
526 | 515 | } |
|
527 | 516 | |
|
517 | /* Set $CHGHG to the path of the hg executable we intend to use. This | |
|
518 | * is a no-op if $CHGHG was expliclty specified, but otherwise this | |
|
519 | * ensures that we will spawn a new command server if we connect to an | |
|
520 | * existing one running from a different executable. This should only | |
|
521 | * only be needed when chg is built with HGPATHREL since otherwise the | |
|
522 | * hg executable used when CHGHG is absent should be deterministic. | |
|
523 | * */ | |
|
524 | if (setenv("CHGHG", gethgcmd(), 1) != 0) | |
|
525 | abortmsgerrno("failed to setenv"); | |
|
526 | ||
|
528 | 527 | hgclient_t *hgc; |
|
529 | 528 | size_t retry = 0; |
|
530 | 529 | while (1) { |
@@ -553,3 +553,20 b" FIXME: Run 4 should not be >3x Run 1's n" | |||
|
553 | 553 | $ filteredchg log -r . --no-profile |
|
554 | 554 | $ filteredchg log -r . |
|
555 | 555 | Sample count: * (glob) |
|
556 | ||
|
557 | chg setting CHGHG itself | |
|
558 | ------------------------ | |
|
559 | ||
|
560 | If CHGHG is not set, chg will set it before spawning the command server. | |
|
561 | $ hg --kill-chg-daemon | |
|
562 | $ HG=$CHGHG CHGHG= CHGDEBUG= hg debugshell -c \ | |
|
563 | > 'ui.write(b"CHGHG=%s\n" % ui.environ.get(b"CHGHG"))' 2>&1 \ | |
|
564 | > | egrep 'CHGHG|start' | |
|
565 | chg: debug: * start cmdserver at * (glob) | |
|
566 | CHGHG=/*/install/bin/hg (glob) | |
|
567 | ||
|
568 | Running the same command a second time shouldn't spawn a new command server. | |
|
569 | $ HG=$CHGHG CHGHG= CHGDEBUG= hg debugshell -c \ | |
|
570 | > 'ui.write(b"CHGHG=%s\n" % ui.environ.get(b"CHGHG"))' 2>&1 \ | |
|
571 | > | egrep 'CHGHG|start' | |
|
572 | CHGHG=/*/install/bin/hg (glob) |
General Comments 0
You need to be logged in to leave comments.
Login now