comparison mercurial/util.py @ 2448:b77a2ef61b81

replace os.stat with os.lstat in some where.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Fri, 16 Jun 2006 12:58:24 -0700
parents e9b5749e4de3
children d610bcfd66a8 fe1689273f84
comparison
equal deleted inserted replaced
2447:cd00531ecc16 2448:b77a2ef61b81
472 def _readlock_file(pathname): 472 def _readlock_file(pathname):
473 return posixfile(pathname).read() 473 return posixfile(pathname).read()
474 474
475 def nlinks(pathname): 475 def nlinks(pathname):
476 """Return number of hardlinks for the given file.""" 476 """Return number of hardlinks for the given file."""
477 return os.stat(pathname).st_nlink 477 return os.lstat(pathname).st_nlink
478 478
479 if hasattr(os, 'link'): 479 if hasattr(os, 'link'):
480 os_link = os.link 480 os_link = os.link
481 else: 481 else:
482 def os_link(src, dst): 482 def os_link(src, dst):
623 pf = pf[1:-1] # Remove the quotes 623 pf = pf[1:-1] # Remove the quotes
624 return pf 624 return pf
625 625
626 def is_exec(f, last): 626 def is_exec(f, last):
627 """check whether a file is executable""" 627 """check whether a file is executable"""
628 return (os.stat(f).st_mode & 0100 != 0) 628 return (os.lstat(f).st_mode & 0100 != 0)
629 629
630 def set_exec(f, mode): 630 def set_exec(f, mode):
631 s = os.stat(f).st_mode 631 s = os.lstat(f).st_mode
632 if (s & 0100 != 0) == mode: 632 if (s & 0100 != 0) == mode:
633 return 633 return
634 if mode: 634 if mode:
635 # Turn on +x for every +r bit when making a file executable 635 # Turn on +x for every +r bit when making a file executable
636 # and obey umask. 636 # and obey umask.