[PATCH 2 of 2] inotify: add a inotify.pidfile configuration possibility

Nicolas Dumazet nicdumz at gmail.com
Tue Nov 17 01:22:38 CST 2009


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1258439769 -32400
# Node ID afa3c54bdcfc630e0b7722ed42862f7e69049f8e
# Parent  2b925ed9433ede6590835f283a28ecaa8b9baee3
inotify: add a inotify.pidfile configuration possibility

This will mainly help us in our tests to log pids of inotify servers
started implicitely, to make sure that unkilled inotify daemons do not clutter
the output of unrelated tests.

Also desactivate the workaround introduced in 951ec6c7d703

diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
--- a/hgext/inotify/server.py
+++ b/hgext/inotify/server.py
@@ -849,9 +849,14 @@
             finally:
                 self.master.shutdown()
 
-    runargs = None
     if 'inserve' not in sys.argv:
         runargs = [sys.argv[0], 'inserve', '-R', root]
+    else:
+        runargs = sys.argv[:]
+
+    pidfile = ui.config('inotify', 'pidfile')
+    if opts['daemon'] and pidfile is not None and 'pid-file' not in runargs:
+        runargs.append("--pid-file=%s" % pidfile)
 
     service = service()
     logfile = ui.config('inotify', 'log')
diff --git a/tests/test-inotify b/tests/test-inotify
--- a/tests/test-inotify
+++ b/tests/test-inotify
@@ -20,7 +20,11 @@
 cd repo2
 echo b >> a
 # check that daemon started automatically works correctly
-hg status
+# and make sure that inotify.pidfile works
+hg --config "inotify.pidfile=../hg2.pid" status
+
+# make sure that pidfile worked. Output should be silent.
+kill `cat ../hg2.pid`
 
 cd ../repo1
 echo % inserve
diff --git a/tests/test-inotify-dirty-dirstate b/tests/test-inotify-dirty-dirstate
--- a/tests/test-inotify-dirty-dirstate
+++ b/tests/test-inotify-dirty-dirstate
@@ -20,10 +20,10 @@
 
 cd ..
 
-hg --config "extensions.inotify=!" clone test test2
+hg --config "inotify.pidfile=../hg2.pid" clone test test2
+cat ../hg2.pid >> "$DAEMON_PIDS"
+
 cd test2
-hg inserve -d --pid-file=../hg2.pid
-cat ../hg2.pid >> "$DAEMON_PIDS"
 echo bar > bar
 hg add
 hg ci -m bar


More information about the Mercurial-devel mailing list