server: use tryunlink
authorRyan McElroy <rmcelroy@fb.com>
Tue, 21 Mar 2017 06:50:28 -0700
changeset 36529 ce4ddcda868b95d03bf8738c9390f60543d8c16a
parent 36528 ddadb6b0b58e908bf46f803edd8df435ed1b579a
child 36530 18b9d9b95719ae59c64c47f4f7e405349106fed8
push id476
push usergszorc@mozilla.com
push dateWed, 22 Mar 2017 06:06:07 +0000
server: use tryunlink
mercurial/server.py
--- a/mercurial/server.py
+++ b/mercurial/server.py
@@ -2,17 +2,16 @@
 #
 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
 from __future__ import absolute_import
 
-import errno
 import os
 import sys
 import tempfile
 
 from .i18n import _
 
 from . import (
     chgserver,
@@ -55,21 +54,17 @@ def runservice(opts, parentfn=None, init
                     break
             def condfn():
                 return not os.path.exists(lockpath)
             pid = util.rundetached(runargs, condfn)
             if pid < 0:
                 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:
             return
 
     if initfn:
         initfn()