diff hgext/inotify/__init__.py @ 8551:7089d9727867

inotify: modular architecture for inotify clients Put the socket init, query generation and response analysis in a more generic client class.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Tue, 07 Apr 2009 18:39:34 +0900
parents 1536501ade62
children 06561793778e
line wrap: on
line diff
--- a/hgext/inotify/__init__.py	Sat May 23 13:43:11 2009 +0200
+++ b/hgext/inotify/__init__.py	Tue Apr 07 18:39:34 2009 +0900
@@ -13,8 +13,9 @@
 
 from mercurial.i18n import _
 from mercurial import cmdutil, util
-import client, errno, os, server, socket
+import errno, os, server, socket
 from weakref import proxy
+from client import client
 
 def serve(ui, repo, **opts):
     '''start an inotify server for this repository'''
@@ -54,10 +55,11 @@
             files = match.files()
             if '.' in files:
                 files = []
+            cli = client(ui, repo)
             try:
                 if not ignored and not self.inotifyserver:
-                    result = client.query(ui, repo, files, match, False,
-                                          clean, unknown)
+                    result = cli.statusquery(files, match, False,
+                                             clean, unknown)
                     if result and ui.config('inotify', 'debug'):
                         r2 = super(inotifydirstate, self).status(
                             match, False, clean, unknown)
@@ -94,8 +96,8 @@
                     else:
                         # server is started, send query again
                         try:
-                            return client.query(ui, repo, files, match,
-                                         ignored, clean, unknown)
+                            return cli.statusquery(files, match, ignored,
+                                                   clean, unknown)
                         except socket.error, err:
                             ui.warn(_('could not talk to new inotify '
                                            'server: %s\n') % err[-1])