comparison mercurial/util.py @ 5350:1df76921aab3

set_exec: do not chmod a symlink
author Steve Borho <steve@ageia.com>
date Tue, 02 Oct 2007 20:22:33 +0200
parents 5a65d870871d
children efe7ef325737
comparison
equal deleted inserted replaced
5348:8838fe5a236f 5350:1df76921aab3
12 platform-specific details from the core. 12 platform-specific details from the core.
13 """ 13 """
14 14
15 from i18n import _ 15 from i18n import _
16 import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile 16 import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile
17 import os, threading, time, calendar, ConfigParser, locale, glob 17 import os, stat, threading, time, calendar, ConfigParser, locale, glob
18 18
19 try: 19 try:
20 set = set 20 set = set
21 frozenset = frozenset 21 frozenset = frozenset
22 except NameError: 22 except NameError:
1045 """check whether a file is executable""" 1045 """check whether a file is executable"""
1046 return (os.lstat(f).st_mode & 0100 != 0) 1046 return (os.lstat(f).st_mode & 0100 != 0)
1047 1047
1048 def set_exec(f, mode): 1048 def set_exec(f, mode):
1049 s = os.lstat(f).st_mode 1049 s = os.lstat(f).st_mode
1050 if (s & 0100 != 0) == mode: 1050 if stat.S_ISLNK(s) or (s & 0100 != 0) == mode:
1051 return 1051 return
1052 if mode: 1052 if mode:
1053 # Turn on +x for every +r bit when making a file executable 1053 # Turn on +x for every +r bit when making a file executable
1054 # and obey umask. 1054 # and obey umask.
1055 os.chmod(f, s | (s & 0444) >> 2 & ~_umask) 1055 os.chmod(f, s | (s & 0444) >> 2 & ~_umask)