[PATCH STABLE] checknlink: return False if .hgtmp file preexists (issue2517)

Steve Borho steve at borho.org
Wed Nov 24 13:40:49 CST 2010


On Tue, Nov 23, 2010 at 4:45 PM, Adrian Buehlmann <adrian at cadifra.com> wrote:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1290549227 -3600
> # Branch stable
> # Node ID 670f4e98276ddc6a9e43d60e3e4bfe8f49246a67
> # Parent  f08df4d38442bf641859f3de860ce0e5b6ba7763
> checknlink: return False if .hgtmp file preexists (issue2517)
>
> If os_link fails on Windows, errno is always errno.EINVAL,
> so we can't really say if the testlink could not be created
> because (a) the FS doesn't support hardlinks or (b) there
> is a leaked .hgtmp file lying around from a previous crashed
> run.
>
> So let's err on the safe side, keep the code simple and assume
> we can't detect hardlinks in both cases.
>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -722,10 +722,7 @@ def checknlink(testfile):
>
>     try:
>         os_link(testfile, f)
> -    except OSError, inst:
> -        if inst.errno == errno.EINVAL:
> -            # FS doesn't support creating hardlinks
> -            return True
> +    except OSError:
>         return False
>
>     try:

Queued, thanks

-- 
Steve Borho


More information about the Mercurial-devel mailing list