[PATCH 1 of 3 V2] serve: rename --daemon-pipefds to --daemon-postexec

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


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1456160348 0
#      Mon Feb 22 16:59:08 2016 +0000
# Node ID ce768a82f084d15b30acc0e44add463c0ec18587
# Parent  28e1694ca60056d609ae2c8e0ad5cb2891416ea3
serve: rename --daemon-pipefds to --daemon-postexec

Initially we use --daemon-pipefds to pass file descriptors for synchronization.
Later, in order to support Windows, --daemon-pipefds is changed to accept a
file path to unlink instead. The name is outdated since then.

chg client is designed to use flock, which will be held before starting a
server and until the client actually connects to the server it started. The
unlink synchronization approach is not so helpful in this case.

To address the issues, this patch renames pipefds to postexec and the following
patch will allow the value of --daemon-postexec to be things like
'unlink:/path/to/file' or 'none'.

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -189,7 +189,7 @@
 		"--cwd", "/",
 		"--cmdserver", "chgunix",
 		"--address", opts->sockname,
-		"--daemon-pipefds", opts->lockfile,
+		"--daemon-postexec", opts->lockfile,
 		"--pid-file", opts->pidfile,
 		"--config", "extensions.chgserver=",
 		/* wrap root ui so that it can be disabled/enabled by config */
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -758,14 +758,14 @@
             fp.write(str(pid) + '\n')
             fp.close()
 
-    if opts['daemon'] and not opts['daemon_pipefds']:
+    if opts['daemon'] and not opts['daemon_postexec']:
         # Signal child process startup with file removal
         lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
         os.close(lockfd)
         try:
             if not runargs:
                 runargs = util.hgcmd() + sys.argv[1:]
-            runargs.append('--daemon-pipefds=%s' % lockpath)
+            runargs.append('--daemon-postexec=%s' % lockpath)
             # Don't pass --cwd to the child process, because we've already
             # changed directory.
             for i in xrange(1, len(runargs)):
@@ -798,8 +798,8 @@
     if not opts['daemon']:
         writepid(util.getpid())
 
-    if opts['daemon_pipefds']:
-        lockpath = opts['daemon_pipefds']
+    if opts['daemon_postexec']:
+        lockpath = opts['daemon_postexec']
         try:
             os.setsid()
         except AttributeError:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6206,7 +6206,7 @@
     [('A', 'accesslog', '', _('name of access log file to write to'),
      _('FILE')),
     ('d', 'daemon', None, _('run server in background')),
-    ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
+    ('', 'daemon-postexec', '', _('used internally by daemon mode')),
     ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
     # use string type, then we can check if something was passed
     ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
diff --git a/tests/dumbhttp.py b/tests/dumbhttp.py
--- a/tests/dumbhttp.py
+++ b/tests/dumbhttp.py
@@ -38,7 +38,7 @@
     parser.add_option('-f', '--foreground', dest='foreground',
         action='store_true',
         help='do not start the HTTP server in the background')
-    parser.add_option('--daemon-pipefds')
+    parser.add_option('--daemon-postexec')
 
     (options, args) = parser.parse_args()
 
@@ -49,7 +49,7 @@
 
     opts = {'pid_file': options.pid,
             'daemon': not options.foreground,
-            'daemon_pipefds': options.daemon_pipefds}
+            'daemon_postexec': options.daemon_postexec}
     service = simplehttpservice(options.host, options.port)
     cmdutil.service(opts, initfn=service.init, runfn=service.run,
                     runargs=[sys.executable, __file__] + sys.argv[1:])
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -158,7 +158,7 @@
   --config
   --cwd
   --daemon
-  --daemon-pipefds
+  --daemon-postexec
   --debug
   --debugger
   --encoding
@@ -218,7 +218,7 @@
   pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
   push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
   remove: after, force, subrepos, include, exclude
-  serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
+  serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
   status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
   summary: remote
   update: clean, check, date, rev, tool


More information about the Mercurial-devel mailing list