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

Mads Kiilerich mads at kiilerich.com
Sat Jan 5 19:01:05 CST 2013


Remy Blank wrote, On 01/05/2013 05:29 PM:
> # 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.

Thanks.

But please wrap the commit message at 80 characters (or slightly less).

And this posix.split apparently needs some test coverage. That could be 
a couple of doc test cases, tested from test-doctest.py ...

/Mads

> 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