[PATCH] Fix Issue 1371: INotify server raising an error when removing a file

Gerard Korsten soonkia77 at gmail.com
Sat Nov 1 04:43:11 UTC 2008


Hmmm, ignore the previous patch. This is the correct one.
The previous patch breaks when you delete a file with just rm.


# HG changeset patch
# User Gerard Korsten <soonkia77 at gmail.com>
# Date 1225514445 -7200
# Node ID bff1ef35c34a0cf3413a9a93a2b17e28541a6b1f
# Parent  b1981315fafdd12788ab9ea5e7980b6c45826fad
Fix Issue 1371: INotify server raising an error when removing a file

When a file is deleted via hg rm <file> the dirstate marks the file with
a status of 'r'. The physical file has been deleted, but INotify server.py
tries to do a stat on the file after it's been removed. Patch adds a check
for to ensure INotify doesn't do a stat on these files.

diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
--- a/hgext/inotify/server.py
+++ b/hgext/inotify/server.py
@@ -338,11 +338,12 @@
             if not wfn.startswith(wtopdir):
                 continue
             status = state[0]
-            st = self.stat(wfn)
-            if status == 'r' and not st:
+            st=None
+            try:
+                st = self.stat(wfn)
+                self.updatestatus(wfn, st)
+            except:
                 self.updatestatus(wfn, st, status=status)
-            else:
-                self.updatestatus(wfn, st)
         self.check_deleted('!')
         self.check_deleted('r')

@@ -403,8 +404,7 @@
             self.statcache[wpath] = ret
             return ret
         except OSError:
-            self.statcache.pop(wpath, None)
-            raise
+            raise

     def created(self, wpath):
         if wpath == '.hgignore':
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20081101/445bb30f/attachment.html>


More information about the Mercurial-devel mailing list