Mercurial > hg
comparison hgext/chgserver.py @ 29596:71c197d82b7e
chgserver: reorder functions in chgunixservicehandler
This should make it slightly easier to follow the call path.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 22 May 2016 14:05:34 +0900 |
parents | 2c4dc91c4c54 |
children | 581c0c7cb258 |
comparison
equal
deleted
inserted
replaced
29595:2c4dc91c4c54 | 29596:71c197d82b7e |
---|---|
567 # one or more extensions failed to load. mtimehash becomes | 567 # one or more extensions failed to load. mtimehash becomes |
568 # meaningless because we do not know the paths of those extensions. | 568 # meaningless because we do not know the paths of those extensions. |
569 # set mtimehash to an illegal hash value to invalidate the server. | 569 # set mtimehash to an illegal hash value to invalidate the server. |
570 self.hashstate.mtimehash = '' | 570 self.hashstate.mtimehash = '' |
571 | 571 |
572 def _createsymlink(self): | |
573 if self.baseaddress == self.address: | |
574 return | |
575 tempaddress = _tempaddress(self.baseaddress) | |
576 os.symlink(os.path.basename(self.address), tempaddress) | |
577 util.rename(tempaddress, self.baseaddress) | |
578 | |
579 def printbanner(self, address): | |
580 # no "listening at" message should be printed to simulate hg behavior | |
581 pass | |
582 | |
583 def shouldexit(self): | |
584 if not self.issocketowner(): | |
585 self.ui.debug('%s is not owned, exiting.\n' % self.address) | |
586 return True | |
587 if time.time() - self.lastactive > self.idletimeout: | |
588 self.ui.debug('being idle too long. exiting.\n') | |
589 return True | |
590 return False | |
591 | |
592 def newconnection(self): | |
593 self.lastactive = time.time() | |
594 | |
595 def _bind(self, sock): | 572 def _bind(self, sock): |
596 # use a unique temp address so we can stat the file and do ownership | 573 # use a unique temp address so we can stat the file and do ownership |
597 # check later | 574 # check later |
598 tempaddress = _tempaddress(self.address) | 575 tempaddress = _tempaddress(self.address) |
599 util.bindunixsocket(sock, tempaddress) | 576 util.bindunixsocket(sock, tempaddress) |
600 self._socketstat = os.stat(tempaddress) | 577 self._socketstat = os.stat(tempaddress) |
601 # rename will replace the old socket file if exists atomically. the | 578 # rename will replace the old socket file if exists atomically. the |
602 # old server will detect ownership change and exit. | 579 # old server will detect ownership change and exit. |
603 util.rename(tempaddress, self.address) | 580 util.rename(tempaddress, self.address) |
581 | |
582 def _createsymlink(self): | |
583 if self.baseaddress == self.address: | |
584 return | |
585 tempaddress = _tempaddress(self.baseaddress) | |
586 os.symlink(os.path.basename(self.address), tempaddress) | |
587 util.rename(tempaddress, self.baseaddress) | |
604 | 588 |
605 def issocketowner(self): | 589 def issocketowner(self): |
606 try: | 590 try: |
607 stat = os.stat(self.address) | 591 stat = os.stat(self.address) |
608 return (stat.st_ino == self._socketstat.st_ino and | 592 return (stat.st_ino == self._socketstat.st_ino and |
621 os.unlink(self.address) | 605 os.unlink(self.address) |
622 except OSError as exc: | 606 except OSError as exc: |
623 if exc.errno != errno.ENOENT: | 607 if exc.errno != errno.ENOENT: |
624 raise | 608 raise |
625 | 609 |
610 def printbanner(self, address): | |
611 # no "listening at" message should be printed to simulate hg behavior | |
612 pass | |
613 | |
614 def shouldexit(self): | |
615 if not self.issocketowner(): | |
616 self.ui.debug('%s is not owned, exiting.\n' % self.address) | |
617 return True | |
618 if time.time() - self.lastactive > self.idletimeout: | |
619 self.ui.debug('being idle too long. exiting.\n') | |
620 return True | |
621 return False | |
622 | |
623 def newconnection(self): | |
624 self.lastactive = time.time() | |
625 | |
626 def createcmdserver(self, repo, conn, fin, fout): | 626 def createcmdserver(self, repo, conn, fin, fout): |
627 return chgcmdserver(self.ui, repo, fin, fout, conn, | 627 return chgcmdserver(self.ui, repo, fin, fout, conn, |
628 self.hashstate, self.baseaddress) | 628 self.hashstate, self.baseaddress) |
629 | 629 |
630 def chgunixservice(ui, repo, opts): | 630 def chgunixservice(ui, repo, opts): |