changeset 3678:7e622c9a9707

Update trusted_users only after we've seen a file not owned by the user
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 18 Nov 2006 23:51:15 -0200
parents 1a0fa3914c46
children 2956948b81f3
files mercurial/ui.py
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Sat Nov 18 23:51:14 2006 -0200
+++ b/mercurial/ui.py	Sat Nov 18 23:51:15 2006 -0200
@@ -101,6 +101,11 @@
             return True
         tusers = self.trusted_users
         tgroups = self.trusted_groups
+        if not tusers:
+            user = util.username()
+            if user is not None:
+                self.trusted_users[user] = 1
+                self.fixconfig(section='trusted')
         if (tusers or tgroups) and '*' not in tusers and '*' not in tgroups:
             user = util.username(st.st_uid)
             group = util.groupname(st.st_gid)
@@ -203,14 +208,11 @@
                 self.interactive = self.configbool("ui", "interactive", True)
 
         # update trust information
-        if section is None or section == 'trusted':
-            user = util.username()
-            if user is not None:
+        if (section is None or section == 'trusted') and self.trusted_users:
+            for user in self.configlist('trusted', 'users'):
                 self.trusted_users[user] = 1
-                for user in self.configlist('trusted', 'users'):
-                    self.trusted_users[user] = 1
-                for group in self.configlist('trusted', 'groups'):
-                    self.trusted_groups[group] = 1
+            for group in self.configlist('trusted', 'groups'):
+                self.trusted_groups[group] = 1
 
     def setconfig(self, section, name, value):
         if not self.overlay: