[PATCH 1 of 2] Inotify dies when removing a directory (Issue 1375)

Gerard Korsten soonkia77 at gmail.com
Fri Nov 7 21:26:25 CST 2008


# HG changeset patch
# User Benoit Boissinot <benoit.boissinot at ens-lyon.org>
# Date 1226106731 -7200
# Node ID 1a2bb72ed51177b62d6fb9ee6162f995723406c3
# Parent  95e1260b8134c7977298b52f53c60a1b69951a79
Inotify dies when removing a directory (Issue 1375)

diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
--- a/hgext/inotify/server.py
+++ b/hgext/inotify/server.py
@@ -20,6 +20,9 @@
 
 class AlreadyStartedException(Exception): pass
 
+class statusdict(dict):
+    status = None
+
 def join(a, b):
     if a:
         if a[-1] == '/':
@@ -223,7 +226,7 @@
     def dir(self, tree, path):
         if path:
             for name in path.split('/'):
-                tree.setdefault(name, {})
+                tree.setdefault(name, statusdict())
                 tree = tree[name]
         return tree
 
@@ -273,7 +276,7 @@
             self.statcache.pop(wfn, None)
         root, fn = self.split(wfn)
         d = self.dir(self.tree, root)
-        oldstatus = d.get(fn)
+        oldstatus = d.setdefault(fn, statusdict()).status
         isdir = False
         if oldstatus:
             try:
@@ -298,11 +301,11 @@
                              (wfn, oldstatus, status))
         if not isdir:
             if status and status != 'i':
-                d[fn] = status
+                d[fn].status = status
                 if status in self.statuskeys:
                     dd = self.dir(self.statustrees[status], root)
                     if oldstatus != status or fn not in dd:
-                        dd[fn] = status
+                        dd.setdefault(fn, statusdict()).status = status
             else:
                 d.pop(fn, None)
 
@@ -364,12 +367,10 @@
 
         for name, val in tree.iteritems():
             path = join(prefix, name)
-            try:
-                if val in states:
-                    yield path, val
-            except TypeError:
-                for p in self.walk(states, val, path):
-                    yield p
+            if val.status is not None and val.status in states:
+                yield path, val
+            for p in self.walk(states, val, path):
+                yield p
 
     def update_hgignore(self):
         # An update of the ignore file can potentially change the


More information about the Mercurial-devel mailing list