chgserver: pass hashstate and base server address to chgcmdserver
authorJun Wu <quark@fb.com>
Mon, 29 Feb 2016 13:46:54 +0000
changeset 28328 e00e57d83653
parent 28327 3ab370f84a23
child 28329 e69343e80aec
chgserver: pass hashstate and base server address to chgcmdserver In order to detect a hash change from a request handler, chg must know the original hashstate. It also needs the base server address to figure out redirect addresses.
hgext/chgserver.py
--- a/hgext/chgserver.py	Mon Feb 29 11:43:25 2016 +0000
+++ b/hgext/chgserver.py	Mon Feb 29 13:46:54 2016 +0000
@@ -334,11 +334,13 @@
 ]
 
 class chgcmdserver(commandserver.server):
-    def __init__(self, ui, repo, fin, fout, sock):
+    def __init__(self, ui, repo, fin, fout, sock, hashstate, baseaddress):
         super(chgcmdserver, self).__init__(
             _newchgui(ui, channeledsystem(fin, fout, 'S')), repo, fin, fout)
         self.clientsock = sock
         self._oldios = []  # original (self.ch, ui.fp, fd) before "attachio"
+        self.hashstate = hashstate
+        self.baseaddress = baseaddress
 
     def cleanup(self):
         # dispatch._runcatch() does not flush outputs if exception is not
@@ -493,7 +495,8 @@
         os.setpgid(0, 0)
         ui = self.server.ui
         repo = self.server.repo
-        sv = chgcmdserver(ui, repo, self.rfile, self.wfile, self.connection)
+        sv = chgcmdserver(ui, repo, self.rfile, self.wfile, self.connection,
+                          self.server.hashstate, self.server.baseaddress)
         try:
             try:
                 sv.serve()
@@ -588,6 +591,8 @@
                   SocketServer.UnixStreamServer):
             ui = self.ui
             repo = self.repo
+            hashstate = self.hashstate
+            baseaddress = self.baseaddress
         self.server = cls(self.address, _requesthandler)
         self.server.idletimeout = self.ui.configint(
             'chgserver', 'idletimeout', self.server.idletimeout)