diff hgext/chgserver.py @ 28535:aa082a8125da

chgserver: add an explicit "reconnect" instruction to validate In some rare cases (next patch), we may want validate to do "unlink" without forcing the client reconnect. This patch addes a new "reconnect" instruction and makes "unlink" not to reconnect by default.
author Jun Wu <quark@fb.com>
date Mon, 14 Mar 2016 13:48:33 +0000
parents 3bf2892f685f
children a979f5b03320
line wrap: on
line diff
--- a/hgext/chgserver.py	Mon Mar 14 11:06:34 2016 +0000
+++ b/hgext/chgserver.py	Mon Mar 14 13:48:33 2016 +0000
@@ -427,10 +427,16 @@
         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.
+            - "redirect $path", the client should attempt to connect to $path
+              first. If it does not work, start a new server. It implies
+              "reconnect".
             - "exit $n", the client should exit directly with code n.
               This may happen if we cannot parse the config.
+            - "reconnect", the client should close the connection and
+              reconnect.
+        If neither "reconnect" nor "redirect" is included in the instruction
+        list, the client can continue with this server after completing all
+        the instructions.
         """
         args = self._readlist()
         try:
@@ -445,6 +451,7 @@
         if newhash.mtimehash != self.hashstate.mtimehash:
             addr = _hashaddress(self.baseaddress, self.hashstate.confighash)
             insts.append('unlink %s' % addr)
+            insts.append('reconnect')
         if newhash.confighash != self.hashstate.confighash:
             addr = _hashaddress(self.baseaddress, newhash.confighash)
             insts.append('redirect %s' % addr)