Patchwork [06,of,10] chgserver: pass hashstate and base server address to chgcmdserver

login
register
mail settings
Submitter Jun Wu
Date March 2, 2016, 10:44 a.m.
Message ID <9821d8ed7874129231a8.1456915448@x1c>
Download mbox | patch
Permalink /patch/13526/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - March 2, 2016, 10:44 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1456753614 0
#      Mon Feb 29 13:46:54 2016 +0000
# Node ID 9821d8ed7874129231a85e86131d37d02f01f129
# Parent  228cda48daee93dc23dc512b9390c9eadfd93f19
chgserver: pass hashstate and base server address to chgcmdserver

In order to detect hash change from a request handler, it must know the
original hashstate. It also needs the base server address to figure out
redirect addresses.
timeless - March 2, 2016, 2:31 p.m.
Jun Wu <quark@fb.com> wrote:
> In order to detect hash change from a request handler,

I'd write "a hash change";

>  it must know the

in context, there's no `it` here, I'd write `chg`.

(the second it doesn't need to be changed, because this one will
establish the context for it.)
Yuya Nishihara - March 3, 2016, 3:40 p.m.
On Wed, 2 Mar 2016 10:44:08 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1456753614 0
> #      Mon Feb 29 13:46:54 2016 +0000
> # Node ID 9821d8ed7874129231a85e86131d37d02f01f129
> # Parent  228cda48daee93dc23dc512b9390c9eadfd93f19
> chgserver: pass hashstate and base server address to chgcmdserver
> 
> In order to detect hash change from a request handler, it must know the
> original hashstate. It also needs the base server address to figure out
> redirect addresses.

Queued this, thanks.

Patch

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -332,11 +332,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
@@ -491,7 +493,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()
@@ -586,6 +589,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)