comparison mercurial/util.py @ 10896:2d61b612a09d stable

checkexec: use an explicit prefix for the temporary file
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Tue, 13 Apr 2010 21:54:59 +0200
parents 1b45468d3deb
children 5589110e9170 997173e49115
comparison
equal deleted inserted replaced
10885:9e4d120e3c32 10896:2d61b612a09d
662 # a FS remount. Frequently we can detect it if files are created 662 # a FS remount. Frequently we can detect it if files are created
663 # with exec bit on. 663 # with exec bit on.
664 664
665 try: 665 try:
666 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH 666 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
667 fh, fn = tempfile.mkstemp("", "", path) 667 fh, fn = tempfile.mkstemp(dir=path, prefix='hg-checkexec-')
668 try: 668 try:
669 os.close(fh) 669 os.close(fh)
670 m = os.stat(fn).st_mode & 0777 670 m = os.stat(fn).st_mode & 0777
671 new_file_has_exec = m & EXECFLAGS 671 new_file_has_exec = m & EXECFLAGS
672 os.chmod(fn, m ^ EXECFLAGS) 672 os.chmod(fn, m ^ EXECFLAGS)