Mercurial > public > mercurial-scm > hg
comparison mercurial/posix.py @ 8657:3fa92c618624
posix: do not use fstat in isowner
The fstat function was undefined, but never used since a stat object
was always passed in the optional st argument. Passing st is now
mandatory.
This bug crept in when util was split up into posix and windows
modules. The fstat function is still defined in util, but importing it
into posix would create an import cycle which seems unnecessary.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sat, 30 May 2009 23:42:35 +0200 |
parents | 573734e7e6d0 |
children | 0289f384e1e5 |
comparison
equal
deleted
inserted
replaced
8656:284fda4cd093 | 8657:3fa92c618624 |
---|---|
137 elif os.WIFSTOPPED(code): | 137 elif os.WIFSTOPPED(code): |
138 val = os.WSTOPSIG(code) | 138 val = os.WSTOPSIG(code) |
139 return _("stopped by signal %d") % val, val | 139 return _("stopped by signal %d") % val, val |
140 raise ValueError(_("invalid exit code")) | 140 raise ValueError(_("invalid exit code")) |
141 | 141 |
142 def isowner(fp, st=None): | 142 def isowner(st): |
143 """Return True if the file object f belongs to the current user. | 143 """Return True if the stat object st is from the current user.""" |
144 | |
145 The return value of a util.fstat(f) may be passed as the st argument. | |
146 """ | |
147 if st is None: | |
148 st = fstat(fp) | |
149 return st.st_uid == os.getuid() | 144 return st.st_uid == os.getuid() |
150 | 145 |
151 def find_exe(command): | 146 def find_exe(command): |
152 '''Find executable for command searching like which does. | 147 '''Find executable for command searching like which does. |
153 If command is a basename then PATH is searched for command. | 148 If command is a basename then PATH is searched for command. |