[PATCH 09 of 11] server: use tryunlink

Ryan McElroy rm at fb.com
Tue Mar 21 09:54:31 EDT 2017


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1490104228 25200
#      Tue Mar 21 06:50:28 2017 -0700
# Node ID 684d201e116b65e6dff5f9494de064591da57b07
# Parent  35955261dc137fbaa70240b3f8b63326e769d1d6
server: use tryunlink

diff --git a/mercurial/server.py b/mercurial/server.py
--- a/mercurial/server.py
+++ b/mercurial/server.py
@@ -7,7 +7,6 @@
 
 from __future__ import absolute_import
 
-import errno
 import os
 import sys
 import tempfile
@@ -60,11 +59,7 @@ def runservice(opts, parentfn=None, init
                 raise error.Abort(_('child process failed to start'))
             writepid(pid)
         finally:
-            try:
-                os.unlink(lockpath)
-            except OSError as e:
-                if e.errno != errno.ENOENT:
-                    raise
+            util.tryunlink(lockpath)
         if parentfn:
             return parentfn(pid)
         else:


More information about the Mercurial-devel mailing list