Mercurial > hg
changeset 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 |
files | hgext/inotify/server.py |
diffstat | 1 files changed, 21 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/inotify/server.py Fri Apr 17 20:10:47 2009 +0900 +++ b/hgext/inotify/server.py Wed Apr 22 00:23:40 2009 +0900 @@ -583,19 +583,7 @@ def handle_timeout(self): pass - def handle_event(self, fd, event): - sock, addr = self.sock.accept() - - cs = common.recvcs(sock) - version = ord(cs.read(1)) - - if version != common.version: - self.ui.warn(_('received query from incompatible client ' - 'version %d\n') % version) - return - - type = cs.read(4) - + def answer_stat_query(self, cs): names = cs.read().split('\0') states = names.pop() @@ -623,7 +611,7 @@ for f, s in self.repowatcher.walk(states, l, fn): yield f - results = ['\0'.join(r) for r in [ + return ['\0'.join(r) for r in [ genresult('l', self.repowatcher.statustrees['l']), genresult('m', self.repowatcher.statustrees['m']), genresult('a', self.repowatcher.statustrees['a']), @@ -636,6 +624,25 @@ 'c' in states and genresult('n', self.repowatcher.tree) or [], ]] + def handle_event(self, fd, event): + sock, addr = self.sock.accept() + + cs = common.recvcs(sock) + version = ord(cs.read(1)) + + if version != common.version: + self.ui.warn(_('received query from incompatible client ' + 'version %d\n') % version) + return + + type = cs.read(4) + + if type == 'STAT': + results = self.answer_stat_query(cs) + else: + self.ui.warn(_('unrecognized query type: %s\n') % type) + return + try: try: v = chr(common.version)