[PATCH 1 of 1] Fixing issue1542, adding a relevant test

Nicolas Dumazet nicdumz at gmail.com
Wed Mar 25 13:02:30 CDT 2009


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1238003938 -32400
# Node ID 1de26a229f38688af6a46aea724af0df7bf87b60
# Parent  c2ecaf63badee4e973c4d843121139d4d3269f12
Fixing issue1542, adding a relevant test

diff -r c2ecaf63bade -r 1de26a229f38 hgext/inotify/server.py
--- a/hgext/inotify/server.py	Sun Mar 22 20:59:03 2009 +0100
+++ b/hgext/inotify/server.py	Thu Mar 26 02:58:58 2009 +0900
@@ -304,6 +304,12 @@
                         dd[fn] = status
             else:
                 d.pop(fn, None)
+        elif not status:
+            # a directory is being removed, check its contents
+            # (looking in particular for 'unknown' files)
+            for subfile, b in oldstatus.copy().iteritems():
+                self.updatestatus(wfn + '/' + subfile, None)
+
 
     def check_deleted(self, key):
         # Files that had been deleted but were present in the dirstate
@@ -328,6 +334,7 @@
             d = self.dir(self.tree, wroot)
             for fn, kind in entries:
                 wfn = join(wroot, fn)
+                self.add_watch(join(root, fn), self.mask)
                 self.updatestatus(wfn, self.getstat(wfn))
                 ds.pop(wfn, None)
         wtopdir = topdir
@@ -471,10 +478,9 @@
             self.ui.note(_('%s event: deleted %s\n') %
                          (self.event_time(), wpath))
 
+        self.schedule_work(wpath, 'd')
         if evt.mask & inotify.IN_ISDIR:
             self.scan(wpath)
-        else:
-            self.schedule_work(wpath, 'd')
 
     def process_modify(self, wpath, evt):
         if self.ui.debugflag:
diff -r c2ecaf63bade -r 1de26a229f38 tests/test-inotify-issue1542
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-inotify-issue1542	Thu Mar 26 02:58:58 2009 +0900
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" inotify || exit 80
+
+hg init 
+
+touch a
+mkdir dir
+touch dir/b
+touch dir/c
+
+echo "[extensions]" >> $HGRCPATH
+echo "inotify=" >> $HGRCPATH
+
+hg add dir/c
+
+echo % inserve
+hg inserve -d --pid-file=hg.pid 2>&1
+cat hg.pid >> "$DAEMON_PIDS"
+
+hg st
+
+echo % moving dir out
+mv dir ../tmp-test-inotify-issue1542
+
+echo % status
+hg st
+
+sleep 1
+echo "Are we able to kill the service? if not, the service died on some error"
+kill `cat hg.pid` 
+
diff -r c2ecaf63bade -r 1de26a229f38 tests/test-inotify-issue1542.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-inotify-issue1542.out	Thu Mar 26 02:58:58 2009 +0900
@@ -0,0 +1,11 @@
+% inserve
+A dir/c
+? a
+? dir/b
+? hg.pid
+% moving dir out
+% status
+! dir/c
+? a
+? hg.pid
+Are we able to kill the service? if not, the service died on some error


More information about the Mercurial-devel mailing list