comparison mercurial/ui.py @ 3677:1a0fa3914c46

Avoid looking up usernames if the current user owns the .hgrc file Converting uids into usernames may be somewhat expensive when NIS or LDAP is involved.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 18 Nov 2006 23:51:14 -0200
parents d94664748bc1
children 7e622c9a9707
comparison
equal deleted inserted replaced
3676:d94664748bc1 3677:1a0fa3914c46
94 self.quiet = self.verbose = False 94 self.quiet = self.verbose = False
95 95
96 def _is_trusted(self, fp, f, warn=True): 96 def _is_trusted(self, fp, f, warn=True):
97 if not self.check_trusted: 97 if not self.check_trusted:
98 return True 98 return True
99 st = util.fstat(fp)
100 if util.isowner(fp, st):
101 return True
99 tusers = self.trusted_users 102 tusers = self.trusted_users
100 tgroups = self.trusted_groups 103 tgroups = self.trusted_groups
101 if (tusers or tgroups) and '*' not in tusers and '*' not in tgroups: 104 if (tusers or tgroups) and '*' not in tusers and '*' not in tgroups:
102 st = util.fstat(fp)
103 user = util.username(st.st_uid) 105 user = util.username(st.st_uid)
104 group = util.groupname(st.st_gid) 106 group = util.groupname(st.st_gid)
105 if user not in tusers and group not in tgroups: 107 if user not in tusers and group not in tgroups:
106 if warn and self.report_untrusted: 108 if warn and self.report_untrusted:
107 self.warn(_('Not trusting file %s from untrusted ' 109 self.warn(_('Not trusting file %s from untrusted '