# HG changeset patch # User Martin Geisler # Date 1243719755 -7200 # Node ID 3fa92c618624676ac1fc62167014c5fdc336bcc8 # Parent 284fda4cd093f9cc1694d14d684ba0954aee8d11 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. diff -r 284fda4cd093 -r 3fa92c618624 mercurial/posix.py --- a/mercurial/posix.py Sat May 30 23:20:30 2009 +0200 +++ b/mercurial/posix.py Sat May 30 23:42:35 2009 +0200 @@ -139,13 +139,8 @@ return _("stopped by signal %d") % val, val raise ValueError(_("invalid exit code")) -def isowner(fp, st=None): - """Return True if the file object f belongs to the current user. - - The return value of a util.fstat(f) may be passed as the st argument. - """ - if st is None: - st = fstat(fp) +def isowner(st): + """Return True if the stat object st is from the current user.""" return st.st_uid == os.getuid() def find_exe(command): diff -r 284fda4cd093 -r 3fa92c618624 mercurial/ui.py --- a/mercurial/ui.py Sat May 30 23:20:30 2009 +0200 +++ b/mercurial/ui.py Sat May 30 23:42:35 2009 +0200 @@ -40,7 +40,7 @@ def _is_trusted(self, fp, f): st = util.fstat(fp) - if util.isowner(fp, st): + if util.isowner(st): return True tusers, tgroups = self._trustusers, self._trustgroups diff -r 284fda4cd093 -r 3fa92c618624 mercurial/windows.py --- a/mercurial/windows.py Sat May 30 23:20:30 2009 +0200 +++ b/mercurial/windows.py Sat May 30 23:42:35 2009 +0200 @@ -164,7 +164,7 @@ # if you change this stub into a real check, please try to implement the # username and groupname functions above, too. -def isowner(fp, st=None): +def isowner(st): return True def find_exe(command): diff -r 284fda4cd093 -r 3fa92c618624 tests/test-trusted.py --- a/tests/test-trusted.py Sat May 30 23:20:30 2009 +0200 +++ b/tests/test-trusted.py Sat May 30 23:42:35 2009 +0200 @@ -44,7 +44,7 @@ return group util.groupname = groupname - def isowner(fp, st=None): + def isowner(st): return user == cuser util.isowner = isowner