# HG changeset patch # User Nicolas Dumazet # Date 2009-03-26 10:01:06 # Node ID 67e59a9886d5902de5b94cd2552d854b6292ec63 # Parent 3e0c28145e6a0dc1b9d05bd6321e33007e0c9eab Fixing issue1542, adding a relevant test inotify is smart enough to notify you about any changes in a directory, even if you only watch the directory, and none if its contents: the recursive add_watch I added was unnecessary. The only thing that matters here is the recursive status update on directory deletion. And scan() has to be called _before_ the deferred call is registered. (race condition: depending on the times, the previous patch could apparently fail on the provided test. It's not the case anymore.) diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py --- a/hgext/inotify/server.py +++ b/hgext/inotify/server.py @@ -304,6 +304,11 @@ class Watcher(object): dd[fn] = status else: d.pop(fn, None) + elif not status: + # a directory is being removed, check its contents + 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 @@ -473,8 +478,7 @@ class Watcher(object): if evt.mask & inotify.IN_ISDIR: self.scan(wpath) - else: - self.schedule_work(wpath, 'd') + self.schedule_work(wpath, 'd') def process_modify(self, wpath, evt): if self.ui.debugflag: diff --git a/tests/test-inotify-issue1542 b/tests/test-inotify-issue1542 new file mode 100644 --- /dev/null +++ b/tests/test-inotify-issue1542 @@ -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 --git a/tests/test-inotify-issue1542.out b/tests/test-inotify-issue1542.out new file mode 100644 --- /dev/null +++ b/tests/test-inotify-issue1542.out @@ -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