[PATCH 1 of 4 V3] chgserver: implement validate command

Yuya Nishihara yuya at tcha.org
Sun Mar 6 05:26:43 EST 2016


On Sat, 5 Mar 2016 14:00:10 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1457186219 0
> #      Sat Mar 05 13:56:59 2016 +0000
> # Node ID f9ac561d5843234187751a508b6d557e8903ceac
> # Parent  7cb2f2438f858d14af715682e9b888f8e3f2e475
> chgserver: implement validate command

Queued this with a minor tweak, thanks.

> +    def validate(self):
> +        """reload the config and check if the server is up to date
> +
> +        read a list of '\0' separated arguments.
> +        write a non-empty list of '\0' separated instruction strings or '\0'
> +        if the list is empty.
> +        an instruction string could be either:
> +            - "unlink $path", the client should unlink the path to stop the
> +              outdated server.
> +            - "redirect $path", the client should try to connect to another
> +              server instead.
> +        """
> +        args = self._readlist()
> +        self.ui = _renewui(self.ui, args)
> +        newhash = hashstate.fromui(self.ui, self.hashstate.mtimepaths)
> +        insts = []
> +        if newhash.mtimehash != self.hashstate.mtimehash:
> +            addr = _hashaddress(self.baseaddress, self.hashstate.confighash)
> +            insts.append('unlink %s' % addr)
> +        if newhash.confighash != self.hashstate.confighash:
> +            addr = _hashaddress(self.baseaddress, newhash.confighash)
> +            insts.append('redirect %s' % addr)

I noticed the inconsistency between self.ui and self.hashstate.confighash,
but that's okay so long as the server process is forked per request. If the
server process is permanent, and if the client ignores the "redirect"
instruction and send "runcommand", new extension would be loaded.


More information about the Mercurial-devel mailing list