[PATCH 03 of 10 RFC v2] ui: don't return certain layers when they are supposed to be displayed

David Soria Parra davidsp at fb.com
Sun Mar 12 18:40:26 EDT 2017


# HG changeset patch
# User David Soria Parra <davidsp at 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.

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


More information about the Mercurial-devel mailing list