##// END OF EJS Templates
chgserver: handle ParseError during validate...
Jun Wu -
r28516:3bf2892f default
parent child Browse files
Show More
@@ -0,0 +1,12
1 init repo
2
3 $ hg init foo
4 $ cd foo
5
6 ill-formed config
7
8 $ hg status
9 $ echo '=brokenconfig' >> $HGRCPATH
10 $ hg status
11 hg: parse error at * (glob)
12 [255]
@@ -460,6 +460,11 static void runinstructions(struct cmdse
460 "%s", *pinst + 9);
460 "%s", *pinst + 9);
461 if (r < 0 || r >= (int)sizeof(opts->redirectsockname))
461 if (r < 0 || r >= (int)sizeof(opts->redirectsockname))
462 abortmsg("redirect path is too long (%d)", r);
462 abortmsg("redirect path is too long (%d)", r);
463 } else if (strncmp(*pinst, "exit ", 5) == 0) {
464 int n = 0;
465 if (sscanf(*pinst + 5, "%d", &n) != 1)
466 abortmsg("cannot read the exit code");
467 exit(n);
463 } else {
468 } else {
464 abortmsg("unknown instruction: %s", *pinst);
469 abortmsg("unknown instruction: %s", *pinst);
465 }
470 }
@@ -429,9 +429,17 class chgcmdserver(commandserver.server)
429 outdated server.
429 outdated server.
430 - "redirect $path", the client should try to connect to another
430 - "redirect $path", the client should try to connect to another
431 server instead.
431 server instead.
432 - "exit $n", the client should exit directly with code n.
433 This may happen if we cannot parse the config.
432 """
434 """
433 args = self._readlist()
435 args = self._readlist()
436 try:
434 self.ui = _renewui(self.ui, args)
437 self.ui = _renewui(self.ui, args)
438 except error.ParseError as inst:
439 dispatch._formatparse(self.ui.warn, inst)
440 self.ui.flush()
441 self.cresult.write('exit 255')
442 return
435 newhash = hashstate.fromui(self.ui, self.hashstate.mtimepaths)
443 newhash = hashstate.fromui(self.ui, self.hashstate.mtimepaths)
436 insts = []
444 insts = []
437 if newhash.mtimehash != self.hashstate.mtimehash:
445 if newhash.mtimehash != self.hashstate.mtimehash:
General Comments 0
You need to be logged in to leave comments. Login now