[PATCH] ui: always report untrusted hgrc files when debug enabled

Ry4an Brase ry4an-hg at ry4an.org
Fri Feb 25 23:27:20 CST 2011


# HG changeset patch
# User Ry4an Brase <ry4an-hg at ry4an.org>
# Date 1298697984 21600
# Node ID 2c9f808cef519efca6226376b9754600be44a9f2
# Parent  643b8212813e631b5525049fc4321a34a4def105
ui: always report untrusted hgrc files when debug enabled

It was suggested in IRC that people disabling the reporting of unstructed hgrc
files can masquerade as problems.  This makes sure untrusted hgrc files are
always reported if --debug is used.

diff -r 643b8212813e -r 2c9f808cef51 mercurial/ui.py
--- a/mercurial/ui.py	Wed Feb 16 15:02:30 2011 +0100
+++ b/mercurial/ui.py	Fri Feb 25 23:26:24 2011 -0600
@@ -122,8 +122,8 @@
             self.quiet = not self.debugflag and self.configbool('ui', 'quiet')
             if self.verbose and self.quiet:
                 self.quiet = self.verbose = False
-            self._reportuntrusted = self.configbool("ui", "report_untrusted",
-                                        True)
+            self._reportuntrusted = self.debugflag or self.configbool("ui",
+                "report_untrusted", True)
             self.tracebackflag = self.configbool('ui', 'traceback', False)
 
         if section in (None, 'trusted'):
diff -r 643b8212813e -r 2c9f808cef51 tests/test-trusted.py
--- a/tests/test-trusted.py	Wed Feb 16 15:02:30 2011 +0100
+++ b/tests/test-trusted.py	Fri Feb 25 23:26:24 2011 -0600
@@ -11,7 +11,8 @@
 f.close()
 
 def testui(user='foo', group='bar', tusers=(), tgroups=(),
-           cuser='foo', cgroup='bar', debug=False, silent=False):
+           cuser='foo', cgroup='bar', debug=False, silent=False,
+           report=True):
     # user, group => owners of the file
     # tusers, tgroups => trusted users/groups
     # cuser, cgroup => user/group of the current process
@@ -61,6 +62,7 @@
 
     u = ui.ui()
     u.setconfig('ui', 'debug', str(bool(debug)))
+    u.setconfig('ui', 'report_untrusted', str(bool(report)))
     u.readconfig('.hg/hgrc')
     if silent:
         return u
@@ -131,6 +133,12 @@
 print "# prints debug warnings"
 u = testui(user='abc', group='def', cuser='foo', debug=True)
 
+print "# report_untrusted enabled without debug hides warnings"
+u = testui(user='abc', group='def', cuser='foo', report=False)
+
+print "# report_untrusted enabled with debug shows warnings"
+u = testui(user='abc', group='def', cuser='foo', debug=True, report=False)
+
 print "# ui.readconfig sections"
 filename = 'foobar'
 f = open(filename, 'w')
diff -r 643b8212813e -r 2c9f808cef51 tests/test-trusted.py.out
--- a/tests/test-trusted.py.out	Wed Feb 16 15:02:30 2011 +0100
+++ b/tests/test-trusted.py.out	Fri Feb 25 23:26:24 2011 -0600
@@ -136,6 +136,25 @@
 .ignoring untrusted configuration option paths.local = /another/path
 . local = /another/path
 
+# report_untrusted enabled without debug hides warnings
+# different user, different group
+trusted
+    global = /some/path
+untrusted
+. . global = /some/path
+. . local = /another/path
+
+# report_untrusted enabled with debug shows warnings
+# different user, different group
+Not trusting file .hg/hgrc from untrusted user abc, group def
+trusted
+ignoring untrusted configuration option paths.local = /another/path
+    global = /some/path
+untrusted
+. . global = /some/path
+.ignoring untrusted configuration option paths.local = /another/path
+. local = /another/path
+
 # ui.readconfig sections
 quux
 


More information about the Mercurial-devel mailing list