Patchwork [3,of,6,RFC] ui: don't return certain layers when they are supposed to be displayed

login
register
mail settings
Submitter David Soria Parra
Date March 12, 2017, 8:10 p.m.
Message ID <ef5ce5325596fe5fef01.1489349443@davidsp-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/19233/
State Superseded
Headers show

Comments

David Soria Parra - March 12, 2017, 8:10 p.m.
# HG changeset patch
# User David Soria Parra <davidsp@fb.com>
# Date 1489349206 25200
#      Sun Mar 12 13:06:46 2017 -0700
# Node ID ef5ce5325596fe5fef014a320abae0f0d5980f3d
# Parent  084a30b54810d05c8b44d22fcab2ef6f783a9f7c
ui: don't return certain layers when they are supposed to be displayed

This is a hack to distinguish visibility for a certain configuration. As we have
layers in place, we can give them a visibility, allowing us to have internal
settings switched on without them showing up in `hg showconfig`. This is useful
for extension to set a list of default flags to trigger behavior.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -360,11 +360,15 @@ 
             cfg.set(section, name, value, source)
         self.fixconfig(section=section)
 
-    def _data(self, untrusted):
+    def _data(self, untrusted, includeinternal=True):
+        res = {}
+        if includeinternal:
+            res = self._cfg['defaults']
         if untrusted:
-            return self._cfg['user']
+            res.update(self._cfg['user'])
         else:
-            return self._cfg['trusted']
+            res.update(self._cfg['trusted'])
+        return res
 
     def configsource(self, section, name, untrusted=False):
         return self._data(untrusted).source(section, name)
@@ -670,7 +674,7 @@ 
         return items
 
     def walkconfig(self, untrusted=False):
-        cfg = self._data(untrusted)
+        cfg = self._data(untrusted, includeinternal=False)
         for section in cfg.sections():
             for name, value in self.configitems(section, untrusted):
                 yield section, name, value