changeset 8791:23730a475363

inotify.server: the decorator eventaction() shouldn't be a method of repowatcher
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 13 Jun 2009 18:41:28 +0200
parents 72af80052bd9
children 3e23b1d20837
files hgext/inotify/server.py
diffstat 1 files changed, 18 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/inotify/server.py	Sat Jun 13 18:14:50 2009 +0200
+++ b/hgext/inotify/server.py	Sat Jun 13 18:41:28 2009 +0200
@@ -142,6 +142,24 @@
     def shutdown(self):
         raise NotImplementedError
 
+def eventaction(code):
+    """
+    Decorator to help handle events in repowatcher
+    """
+    def decorator(f):
+        def wrapper(self, wpath):
+            if code == 'm' and wpath in self.lastevent and \
+                self.lastevent[wpath] in 'cm':
+                return
+            self.lastevent[wpath] = code
+            self.timeout = 250
+
+            f(self, wpath)
+
+        wrapper.func_name = f.func_name
+        return wrapper
+    return decorator
+
 class repowatcher(pollable):
     """
     Watches inotify events
@@ -439,21 +457,6 @@
             self.statcache.pop(wpath, None)
             raise
 
-    def eventaction(code):
-        def decorator(f):
-            def wrapper(self, wpath):
-                if code == 'm' and wpath in self.lastevent and \
-                    self.lastevent[wpath] in 'cm':
-                    return
-                self.lastevent[wpath] = code
-                self.timeout = 250
-
-                f(self, wpath)
-
-            wrapper.func_name = f.func_name
-            return wrapper
-        return decorator
-
     @eventaction('c')
     def created(self, wpath):
         if wpath == '.hgignore':