# HG changeset patch # User Patrick Mezard # Date 1186388764 -7200 # Node ID 7e2385a31933c642890dc11539305126bdedf1b5 # Parent 1b970cdab695f618e871870a5bc8ccbf1cd0a654 hghave: detect executable permission availability. diff --git a/tests/hghave b/tests/hghave --- a/tests/hghave +++ b/tests/hghave @@ -5,6 +5,7 @@ if all features are there, non-zero othe import optparse import os import sys +import tempfile def has_symlink(): return hasattr(os, "symlink") @@ -12,9 +13,20 @@ def has_symlink(): def has_fifo(): return hasattr(os, "mkfifo") +def has_executablebit(): + fd, path = tempfile.mkstemp() + os.close(fd) + try: + s = os.lstat(path).st_mode + os.chmod(path, s | 0100) + return (os.lstat(path).st_mode & 0100 != 0) + finally: + os.remove(path) + checks = { "symlink": (has_symlink, "symbolic links"), "fifo": (has_fifo, "named pipes"), + "execbit": (has_executablebit, "executable bit"), } def list_features():