Mercurial > hg
comparison hgext/inotify/server.py @ 8554:47d7347484f5
inotify: put STAT-specific query answer generation part in its own method
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Wed, 22 Apr 2009 00:23:40 +0900 |
parents | e387ecd7a6ed |
children | 3e09bc5fee12 |
comparison
equal
deleted
inserted
replaced
8553:e387ecd7a6ed | 8554:47d7347484f5 |
---|---|
581 self.fileno = self.sock.fileno | 581 self.fileno = self.sock.fileno |
582 | 582 |
583 def handle_timeout(self): | 583 def handle_timeout(self): |
584 pass | 584 pass |
585 | 585 |
586 def handle_event(self, fd, event): | 586 def answer_stat_query(self, cs): |
587 sock, addr = self.sock.accept() | |
588 | |
589 cs = common.recvcs(sock) | |
590 version = ord(cs.read(1)) | |
591 | |
592 if version != common.version: | |
593 self.ui.warn(_('received query from incompatible client ' | |
594 'version %d\n') % version) | |
595 return | |
596 | |
597 type = cs.read(4) | |
598 | |
599 names = cs.read().split('\0') | 587 names = cs.read().split('\0') |
600 | 588 |
601 states = names.pop() | 589 states = names.pop() |
602 | 590 |
603 self.ui.note(_('answering query for %r\n') % states) | 591 self.ui.note(_('answering query for %r\n') % states) |
621 yield fn | 609 yield fn |
622 except TypeError: | 610 except TypeError: |
623 for f, s in self.repowatcher.walk(states, l, fn): | 611 for f, s in self.repowatcher.walk(states, l, fn): |
624 yield f | 612 yield f |
625 | 613 |
626 results = ['\0'.join(r) for r in [ | 614 return ['\0'.join(r) for r in [ |
627 genresult('l', self.repowatcher.statustrees['l']), | 615 genresult('l', self.repowatcher.statustrees['l']), |
628 genresult('m', self.repowatcher.statustrees['m']), | 616 genresult('m', self.repowatcher.statustrees['m']), |
629 genresult('a', self.repowatcher.statustrees['a']), | 617 genresult('a', self.repowatcher.statustrees['a']), |
630 genresult('r', self.repowatcher.statustrees['r']), | 618 genresult('r', self.repowatcher.statustrees['r']), |
631 genresult('!', self.repowatcher.statustrees['!']), | 619 genresult('!', self.repowatcher.statustrees['!']), |
633 and genresult('?', self.repowatcher.statustrees['?']) | 621 and genresult('?', self.repowatcher.statustrees['?']) |
634 or [], | 622 or [], |
635 [], | 623 [], |
636 'c' in states and genresult('n', self.repowatcher.tree) or [], | 624 'c' in states and genresult('n', self.repowatcher.tree) or [], |
637 ]] | 625 ]] |
626 | |
627 def handle_event(self, fd, event): | |
628 sock, addr = self.sock.accept() | |
629 | |
630 cs = common.recvcs(sock) | |
631 version = ord(cs.read(1)) | |
632 | |
633 if version != common.version: | |
634 self.ui.warn(_('received query from incompatible client ' | |
635 'version %d\n') % version) | |
636 return | |
637 | |
638 type = cs.read(4) | |
639 | |
640 if type == 'STAT': | |
641 results = self.answer_stat_query(cs) | |
642 else: | |
643 self.ui.warn(_('unrecognized query type: %s\n') % type) | |
644 return | |
638 | 645 |
639 try: | 646 try: |
640 try: | 647 try: |
641 v = chr(common.version) | 648 v = chr(common.version) |
642 | 649 |