[PATCH] posix: fix split() for the case where the path is at the root of the filesystem

Remy Blank remy.blank at pobox.com
Sat Jan 5 10:29:55 CST 2013


# HG changeset patch
# User Remy Blank <remy.blank at pobox.com>
# Date 1357401181 -3600
# Node ID 9d750e6d7338555bb8a9a47aac1efed1f7a3219c
# Parent  83aa4359c49f67bcb98fb9c7d885ed4ac7443239
posix: fix split() for the case where the path is at the root of the filesystem

posixpath.split() strips '/' from the dirname *unless it is the root*. This patch reproduces this behavior in posix.split(). The old behavior causes a crash when creating a file at the root of the repo with localrepo.wfile() when the repo is at the root of the filesystem.

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -28,7 +28,7 @@ def split(p):
     nh = ht[0].rstrip('/')
     if nh:
         return nh, ht[1]
-    return ht
+    return ht[0] + '/', ht[1]
 
 def openhardlinks():
     '''return true if it is safe to hold open file handles to hardlinks'''


More information about the Mercurial-devel mailing list