Mercurial > hg
changeset 44617:1e459ac4cb48
chg: be stricter about checking invocation of `serve` command
Few tests run serve command in form of `hg -R <repo> serve` which leads to chg
thinking that it's not a serve command and failing tests.
We become more stricter in checking for the serve command.
This fixes test-server-view.t, test-remote-hidden.t, test-remotefilelog-http.t,
test-phases-exchange.t, test-wireproto-content-redirects.t with chg.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 24 Mar 2020 15:21:11 +0530 |
parents | bdc8a5944d44 |
children | 97265a0c0a42 |
files | contrib/chg/chg.c |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/chg/chg.c Mon Mar 23 23:43:29 2020 +0530 +++ b/contrib/chg/chg.c Tue Mar 24 15:21:11 2020 +0530 @@ -374,8 +374,7 @@ /* * Test whether the command is unsupported or not. This is not designed to - * cover all cases. But it's fast, does not depend on the server and does - * not return false positives. + * cover all cases. But it's fast, does not depend on the server. */ static int isunsupported(int argc, const char *argv[]) { @@ -388,7 +387,12 @@ for (i = 0; i < argc; ++i) { if (strcmp(argv[i], "--") == 0) break; - if (i == 0 && strcmp("serve", argv[i]) == 0) + /* + * there can be false positives but no false negative + * we cannot assume `serve` will always be first argument + * because global options can be passed before the command name + */ + if (strcmp("serve", argv[i]) == 0) state |= SERVE; else if (strcmp("-d", argv[i]) == 0 || strcmp("--daemon", argv[i]) == 0)