inotify.server: the decorator eventaction() shouldn't be a method of repowatcher
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 13 Jun 2009 18:41:28 +0200
changeset 8791 23730a475363
parent 8790 72af80052bd9
child 8792 3e23b1d20837
inotify.server: the decorator eventaction() shouldn't be a method of repowatcher
hgext/inotify/server.py
--- 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':