# HG changeset patch # User Benoit Boissinot # Date 2009-11-20 01:34:56 # Node ID b5170b8b32a5a8a77a9062da5726c0e4a667410d # Parent 30a2aa8e529055d3f182f54cb2a9ac0a72c32b76 # Parent 97eda2133a9bd2a1f2cafd572e18d6c8053e19dd merge with stable 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 @@ def start(ui, dirstate, root, opts): 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/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -571,7 +571,7 @@ def service(opts, parentfn=None, initfn= if parentfn: return parentfn(pid) else: - os._exit(0) + return if initfn: initfn() diff --git a/tests/test-inotify b/tests/test-inotify --- a/tests/test-inotify +++ b/tests/test-inotify @@ -2,7 +2,8 @@ "$TESTDIR/hghave" inotify || exit 80 -hg init +hg init repo1 +cd repo1 touch a b c d e mkdir dir @@ -10,10 +11,22 @@ mkdir dir/bar touch dir/x dir/y dir/bar/foo hg ci -Am m +cd .. +hg clone repo1 repo2 echo "[extensions]" >> $HGRCPATH echo "inotify=" >> $HGRCPATH +cd repo2 +echo b >> a +# check that daemon started automatically works correctly +# 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 hg inserve -d --pid-file=hg.pid cat hg.pid >> "$DAEMON_PIDS" 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 @@ hg ci -m foo 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 diff --git a/tests/test-inotify-issue1208.out b/tests/test-inotify-issue1208.out --- a/tests/test-inotify-issue1208.out +++ b/tests/test-inotify-issue1208.out @@ -1,5 +1,6 @@ % fail abort: could not start server: File exists +could not talk to new inotify server: No such file or directory abort: could not start server: File exists % inserve % status diff --git a/tests/test-inotify.out b/tests/test-inotify.out --- a/tests/test-inotify.out +++ b/tests/test-inotify.out @@ -6,6 +6,9 @@ adding dir/bar/foo adding dir/x adding dir/y adding e +updating to branch default +8 files updated, 0 files merged, 0 files removed, 0 files unresolved +M a % inserve ? hg.pid % clean