Patchwork [2,of,4,stateful-chg] commandserver: move printbanner logic to bindsocket

login
register
mail settings
Submitter Jun Wu
Date May 6, 2017, 11:39 p.m.
Message ID <1adb2037f0d1f8dc2b84.1494113955@x1c>
Download mbox | patch
Permalink /patch/20496/
State Accepted
Headers show

Comments

Jun Wu - May 6, 2017, 11:39 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1493576465 25200
#      Sun Apr 30 11:21:05 2017 -0700
# Node ID 1adb2037f0d1f8dc2b84b3804a763ec4c70c00ac
# Parent  9652453e198e525362e93c84712fb29c3297cf13
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 1adb2037f0d1
commandserver: move printbanner logic to bindsocket

bindsocket now handles listen automatically. "printbanner" seems to be just
a part of "bindsocket". This simplifies the interface a bit.

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -493,4 +493,5 @@  class chgunixservicehandler(object):
         self._bind(sock)
         self._createsymlink()
+        # no "listening at" message should be printed to simulate hg behavior
 
     def _inithashstate(self, address):
@@ -547,8 +548,4 @@  class chgunixservicehandler(object):
         util.tryunlink(self._realaddress)
 
-    def printbanner(self, address):
-        # no "listening at" message should be printed to simulate hg behavior
-        pass
-
     def shouldexit(self):
         if not self._issocketowner():
diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -411,12 +411,10 @@  class unixservicehandler(object):
         util.bindunixsocket(sock, address)
         sock.listen(socket.SOMAXCONN)
+        self.ui.status(_('listening at %s\n') % address)
+        self.ui.flush()  # avoid buffering of status message
 
     def unlinksocket(self, address):
         os.unlink(address)
 
-    def printbanner(self, address):
-        self.ui.status(_('listening at %s\n') % address)
-        self.ui.flush()  # avoid buffering of status message
-
     def shouldexit(self):
         """True if server should shut down; checked per pollinterval"""
@@ -456,5 +454,4 @@  class unixforkingservice(object):
         o = signal.signal(signal.SIGCHLD, self._sigchldhandler)
         self._oldsigchldhandler = o
-        self._servicehandler.printbanner(self.address)
         self._socketunlinked = False