commandserver: move printbanner logic to bindsocket
authorJun Wu <quark@fb.com>
Sun, 30 Apr 2017 11:21:05 -0700
changeset 32277 1ada3d18e7fb
parent 32276 c8b9943c07eb
child 32278 8a660af9dbe3
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.
mercurial/chgserver.py
mercurial/commandserver.py
--- a/mercurial/chgserver.py	Sun Apr 30 11:08:27 2017 -0700
+++ b/mercurial/chgserver.py	Sun Apr 30 11:21:05 2017 -0700
@@ -492,6 +492,7 @@
         self._checkextensions()
         self._bind(sock)
         self._createsymlink()
+        # no "listening at" message should be printed to simulate hg behavior
 
     def _inithashstate(self, address):
         self._baseaddress = address
@@ -546,10 +547,6 @@
         # the client will start a new server on demand.
         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():
             self.ui.debug('%s is not owned, exiting.\n' % self._realaddress)
--- a/mercurial/commandserver.py	Sun Apr 30 11:08:27 2017 -0700
+++ b/mercurial/commandserver.py	Sun Apr 30 11:21:05 2017 -0700
@@ -410,14 +410,12 @@
     def bindsocket(self, sock, address):
         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"""
         return False
@@ -455,7 +453,6 @@
         self._servicehandler.bindsocket(self._sock, self.address)
         o = signal.signal(signal.SIGCHLD, self._sigchldhandler)
         self._oldsigchldhandler = o
-        self._servicehandler.printbanner(self.address)
         self._socketunlinked = False
 
     def _unlinksocket(self):