[PATCH 1 of 2] win32.py: let samefile and samedevice work on directories too
Adrian Buehlmann
adrian at cadifra.com
Thu Jun 14 04:55:56 CDT 2012
On 2012-06-14 11:44, Adrian Buehlmann wrote:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1339664600 -7200
> # Node ID cbddd5db525031ee953f165cb902048d6a3f1292
> # Parent bdf8c6c61c9b3ff422208e62b498d61d69b12d6c
> win32.py: let samefile and samedevice work on directories too
>
> diff --git a/mercurial/win32.py b/mercurial/win32.py
> --- a/mercurial/win32.py
> +++ b/mercurial/win32.py
> @@ -59,6 +59,8 @@
>
> _OPEN_EXISTING = 3
>
> +_FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
> +
> # SetFileAttributes
> _FILE_ATTRIBUTE_NORMAL = 0x80
> _FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x2000
> @@ -192,7 +194,7 @@
> def _getfileinfo(name):
> fh = _kernel32.CreateFileA(name, 0,
> _FILE_SHARE_READ | _FILE_SHARE_WRITE | _FILE_SHARE_DELETE,
> - None, _OPEN_EXISTING, 0, None)
> + None, _OPEN_EXISTING, _FILE_FLAG_BACKUP_SEMANTICS, None)
> if fh == _INVALID_HANDLE_VALUE:
> _raiseoserror(name)
> try:
I've intentionally *not* sent this for stable, as this might be more
risky than it looks on first sight.
Interactively chatting with python to test samefile and samedevice on
Windows 7 showed that it works all as expected for local NTFS and FAT32
volumes and a share served by a Windows 7 box.
More information about the Mercurial-devel
mailing list