Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/util.py @ 5214:316ce5e85b3e
check exec: return fallback in case of error during the check
If there is any error while checking if exec is supported,
we can return fallback.
fix issue705
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 24 Aug 2007 00:38:08 +0200 |
parents | 84b10dc3dccc |
children | b0bc8cf41ffc |
comparison
equal
deleted
inserted
replaced
5179:156f4c8a12aa | 5214:316ce5e85b3e |
---|---|
791 """ | 791 """ |
792 Check whether the given path is on a filesystem with UNIX-like exec flags | 792 Check whether the given path is on a filesystem with UNIX-like exec flags |
793 | 793 |
794 Requires a directory (like /foo/.hg) | 794 Requires a directory (like /foo/.hg) |
795 """ | 795 """ |
796 fh, fn = tempfile.mkstemp("", "", path) | 796 try: |
797 os.close(fh) | 797 fh, fn = tempfile.mkstemp("", "", path) |
798 m = os.stat(fn).st_mode | 798 os.close(fh) |
799 os.chmod(fn, m ^ 0111) | 799 m = os.stat(fn).st_mode |
800 r = (os.stat(fn).st_mode != m) | 800 os.chmod(fn, m ^ 0111) |
801 os.unlink(fn) | 801 r = (os.stat(fn).st_mode != m) |
802 os.unlink(fn) | |
803 except (IOError,OSError): | |
804 # we don't care, the user probably won't be able to commit anyway | |
805 return False | |
802 return r | 806 return r |
803 | 807 |
804 def execfunc(path, fallback): | 808 def execfunc(path, fallback): |
805 '''return an is_exec() function with default to fallback''' | 809 '''return an is_exec() function with default to fallback''' |
806 if checkexec(path): | 810 if checkexec(path): |