equal
deleted
inserted
replaced
38 skiphash = False # whether to skip config or env change checks |
38 skiphash = False # whether to skip config or env change checks |
39 """ |
39 """ |
40 |
40 |
41 from __future__ import absolute_import |
41 from __future__ import absolute_import |
42 |
42 |
43 import SocketServer |
|
44 import errno |
43 import errno |
45 import gc |
44 import gc |
46 import hashlib |
45 import hashlib |
47 import inspect |
46 import inspect |
48 import os |
47 import os |
65 error, |
64 error, |
66 extensions, |
65 extensions, |
67 osutil, |
66 osutil, |
68 util, |
67 util, |
69 ) |
68 ) |
|
69 |
|
70 socketserver = util.socketserver |
70 |
71 |
71 # Note for extension authors: ONLY specify testedwith = 'internal' for |
72 # Note for extension authors: ONLY specify testedwith = 'internal' for |
72 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
73 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
73 # be specifying the version(s) of Mercurial they are tested with, or |
74 # be specifying the version(s) of Mercurial they are tested with, or |
74 # leave the attribute unspecified. |
75 # leave the attribute unspecified. |
528 'getpager': getpager, |
529 'getpager': getpager, |
529 'setenv': setenv, |
530 'setenv': setenv, |
530 'setumask': setumask}) |
531 'setumask': setumask}) |
531 |
532 |
532 # copied from mercurial/commandserver.py |
533 # copied from mercurial/commandserver.py |
533 class _requesthandler(SocketServer.StreamRequestHandler): |
534 class _requesthandler(socketserver.StreamRequestHandler): |
534 def handle(self): |
535 def handle(self): |
535 # use a different process group from the master process, making this |
536 # use a different process group from the master process, making this |
536 # process pass kernel "is_current_pgrp_orphaned" check so signals like |
537 # process pass kernel "is_current_pgrp_orphaned" check so signals like |
537 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored. |
538 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored. |
538 os.setpgid(0, 0) |
539 os.setpgid(0, 0) |
601 break |
602 break |
602 self.shutdown() |
603 self.shutdown() |
603 |
604 |
604 def process_request(self, request, address): |
605 def process_request(self, request, address): |
605 self.lastactive = time.time() |
606 self.lastactive = time.time() |
606 return SocketServer.ForkingMixIn.process_request( |
607 return socketserver.ForkingMixIn.process_request( |
607 self, request, address) |
608 self, request, address) |
608 |
609 |
609 def server_bind(self): |
610 def server_bind(self): |
610 # use a unique temp address so we can stat the file and do ownership |
611 # use a unique temp address so we can stat the file and do ownership |
611 # check later |
612 # check later |
654 # one chgserver can serve multiple repos. drop repo infomation |
655 # one chgserver can serve multiple repos. drop repo infomation |
655 self.ui.setconfig('bundle', 'mainreporoot', '', 'repo') |
656 self.ui.setconfig('bundle', 'mainreporoot', '', 'repo') |
656 self.repo = None |
657 self.repo = None |
657 self._inithashstate() |
658 self._inithashstate() |
658 self._checkextensions() |
659 self._checkextensions() |
659 class cls(AutoExitMixIn, SocketServer.ForkingMixIn, |
660 class cls(AutoExitMixIn, socketserver.ForkingMixIn, |
660 SocketServer.UnixStreamServer): |
661 socketserver.UnixStreamServer): |
661 ui = self.ui |
662 ui = self.ui |
662 repo = self.repo |
663 repo = self.repo |
663 hashstate = self.hashstate |
664 hashstate = self.hashstate |
664 baseaddress = self.baseaddress |
665 baseaddress = self.baseaddress |
665 self.server = cls(self.address, _requesthandler) |
666 self.server = cls(self.address, _requesthandler) |