[PATCH 2 of 3 V2] serve: allow --deamon-postexec to be 'unlink:path' or 'none'

Jun Wu quark at fb.com
Mon Feb 22 17:59:08 UTC 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1456162202 0
#      Mon Feb 22 17:30:02 2016 +0000
# Node ID 118b386f47cb6e6aa4f231c9ae22bc2e155e7b99
# Parent  ce768a82f084d15b30acc0e44add463c0ec18587
serve: allow --deamon-postexec to be 'unlink:path' or 'none'

This patch changes the format of value of --daemon-postexec. Now it can be
either to unlink a file, or a no-op. The following patch will make chg to
use the no-op option.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -765,7 +765,7 @@
         try:
             if not runargs:
                 runargs = util.hgcmd() + sys.argv[1:]
-            runargs.append('--daemon-postexec=%s' % lockpath)
+            runargs.append('--daemon-postexec=unlink:%s' % lockpath)
             # Don't pass --cwd to the child process, because we've already
             # changed directory.
             for i in xrange(1, len(runargs)):
@@ -799,12 +799,16 @@
         writepid(util.getpid())
 
     if opts['daemon_postexec']:
-        lockpath = opts['daemon_postexec']
+        inst = opts['daemon_postexec']
         try:
             os.setsid()
         except AttributeError:
             pass
-        os.unlink(lockpath)
+        if inst.startswith('unlink:'):
+            lockpath = inst[7:]
+            os.unlink(lockpath)
+        elif inst != 'none':
+            raise error.Abort(_('invalid value for --daemon-postexec'))
         util.hidewindow()
         sys.stdout.flush()
         sys.stderr.flush()



More information about the Mercurial-devel mailing list