##// END OF EJS Templates
chg: fallback to original hg for some unsupported commands or flags...
Jun Wu -
r28260:0a17cfbe default
parent child Browse files
Show More
@@ -448,11 +448,51 b' error:'
448 abortmsg("failed to prepare pager (errno = %d)", errno);
448 abortmsg("failed to prepare pager (errno = %d)", errno);
449 }
449 }
450
450
451 /*
452 * Test whether the command is unsupported or not. This is not designed to
453 * cover all cases. But it's fast, does not depend on the server and does
454 * not return false positives.
455 */
456 static int isunsupported(int argc, const char *argv[])
457 {
458 enum {
459 SERVE = 1,
460 DAEMON = 2,
461 SERVEDAEMON = SERVE | DAEMON,
462 TIME = 4,
463 };
464 unsigned int state = 0;
465 int i;
466 for (i = 0; i < argc; ++i) {
467 if (strcmp(argv[i], "--") == 0)
468 break;
469 if (i == 0 && strcmp("serve", argv[i]) == 0)
470 state |= SERVE;
471 else if (strcmp("-d", argv[i]) == 0 ||
472 strcmp("--daemon", argv[i]) == 0)
473 state |= DAEMON;
474 else if (strcmp("--time", argv[i]) == 0)
475 state |= TIME;
476 }
477 return (state & TIME) == TIME ||
478 (state & SERVEDAEMON) == SERVEDAEMON;
479 }
480
481 static void execoriginalhg(const char *argv[])
482 {
483 debugmsg("execute original hg");
484 if (execvp(gethgcmd(), (char **)argv) < 0)
485 abortmsg("failed to exec original hg (errno = %d)", errno);
486 }
487
451 int main(int argc, const char *argv[], const char *envp[])
488 int main(int argc, const char *argv[], const char *envp[])
452 {
489 {
453 if (getenv("CHGDEBUG"))
490 if (getenv("CHGDEBUG"))
454 enabledebugmsg();
491 enabledebugmsg();
455
492
493 if (isunsupported(argc - 1, argv + 1))
494 execoriginalhg(argv);
495
456 struct cmdserveropts opts;
496 struct cmdserveropts opts;
457 initcmdserveropts(&opts);
497 initcmdserveropts(&opts);
458 setcmdserveropts(&opts);
498 setcmdserveropts(&opts);
General Comments 0
You need to be logged in to leave comments. Login now