Update trusted_users only after we've seen a file not owned by the user
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Sat, 18 Nov 2006 23:51:15 -0200
changeset 3678 7e622c9a9707
parent 3677 1a0fa3914c46
child 3679 2956948b81f3
Update trusted_users only after we've seen a file not owned by the user
mercurial/ui.py
--- 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: