mercurial/chgserver.py
changeset 30619 88efb4fb1975
parent 30618 201b44c8875c
child 30635 a150173da1c1
--- a/mercurial/chgserver.py	Sun Oct 23 17:47:00 2016 +0900
+++ b/mercurial/chgserver.py	Mon Dec 19 22:07:41 2016 +0000
@@ -526,7 +526,12 @@
     return '%s.%d.tmp' % (address, os.getpid())
 
 def _hashaddress(address, hashstr):
-    return '%s-%s' % (address, hashstr)
+    # if the basename of address contains '.', use only the left part. this
+    # makes it possible for the client to pass 'server.tmp$PID' and follow by
+    # an atomic rename to avoid locking when spawning new servers.
+    dirname, basename = os.path.split(address)
+    basename = basename.split('.', 1)[0]
+    return '%s-%s' % (os.path.join(dirname, basename), hashstr)
 
 class chgunixservicehandler(object):
     """Set of operations for chg services"""