changeset 9897:97eda2133a9b stable

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
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Tue, 17 Nov 2009 15:36:09 +0900
parents 2c2f7593ffc4
children b5170b8b32a5 be574a37a8ae a0680daed7b2
files hgext/inotify/server.py tests/test-inotify tests/test-inotify-dirty-dirstate
diffstat 3 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/inotify/server.py	Tue Nov 17 15:00:00 2009 +0900
+++ b/hgext/inotify/server.py	Tue Nov 17 15:36:09 2009 +0900
@@ -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')
--- a/tests/test-inotify	Tue Nov 17 15:00:00 2009 +0900
+++ b/tests/test-inotify	Tue Nov 17 15:36:09 2009 +0900
@@ -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
--- a/tests/test-inotify-dirty-dirstate	Tue Nov 17 15:00:00 2009 +0900
+++ b/tests/test-inotify-dirty-dirstate	Tue Nov 17 15:36:09 2009 +0900
@@ -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