Patchwork [2,of,3] cmdserver: postpone creation of pipe server until run()

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 15, 2014, 10:34 a.m.
Message ID <d6e1a0cd0da71ebd777d.1416047666@mimosa>
Download mbox | patch
Permalink /patch/6743/
State Accepted
Commit bc374458688b4d53bf0b0387735dc859d1448a03
Headers show

Comments

Yuya Nishihara - Nov. 15, 2014, 10:34 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1416024281 -32400
#      Sat Nov 15 13:04:41 2014 +0900
# Node ID d6e1a0cd0da71ebd777d2f35a52b6390ca3915e8
# Parent  546edd445faa8da409bc5df17629705de0d8d774
cmdserver: postpone creation of pipe server until run()

This makes it easy to swap file descriptors while running command server.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -250,13 +250,16 @@  class server(object):
 
 class pipeservice(object):
     def __init__(self, ui, repo, opts):
-        self.server = server(ui, repo, ui.fin, ui.fout)
+        self.ui = ui
+        self.repo = repo
 
     def init(self):
         pass
 
     def run(self):
-        return self.server.serve()
+        ui = self.ui
+        sv = server(ui, self.repo, ui.fin, ui.fout)
+        return sv.serve()
 
 class _requesthandler(SocketServer.StreamRequestHandler):
     def handle(self):