comparison mercurial/ui.py @ 47421:b1b3127227be

config: add an experimental option to list all known config That option is not ready for prime-time, hence the `exp-` prefix. However, this is a good base to start going toward completion. This is also quite useful for developer on its own for now. Differential Revision: https://phab.mercurial-scm.org/D10356
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 09 Apr 2021 17:04:39 +0200
parents c887bab2dccf
children 7a430116f639
comparison
equal deleted inserted replaced
47420:5fbac82a8780 47421:b1b3127227be
946 b"ignoring untrusted configuration option " 946 b"ignoring untrusted configuration option "
947 b"%s.%s = %s\n" % (section, k, v) 947 b"%s.%s = %s\n" % (section, k, v)
948 ) 948 )
949 return items 949 return items
950 950
951 def walkconfig(self, untrusted=False): 951 def walkconfig(self, untrusted=False, all_known=False):
952 defined = self._walk_config(untrusted)
953 if not all_known:
954 for d in defined:
955 yield d
956 return
957 known = self._walk_known()
958 current_defined = next(defined, None)
959 current_known = next(known, None)
960 while current_defined is not None or current_known is not None:
961 if current_defined is None:
962 yield current_known
963 current_known = next(known, None)
964 elif current_known is None:
965 yield current_defined
966 current_defined = next(defined, None)
967 elif current_known[0:2] == current_defined[0:2]:
968 yield current_defined
969 current_defined = next(defined, None)
970 current_known = next(known, None)
971 elif current_known[0:2] < current_defined[0:2]:
972 yield current_known
973 current_known = next(known, None)
974 else:
975 yield current_defined
976 current_defined = next(defined, None)
977
978 def _walk_known(self):
979 for section, items in sorted(self._knownconfig.items()):
980 for k, i in sorted(items.items()):
981 # We don't have a way to display generic well, so skip them
982 if i.generic:
983 continue
984 if callable(i.default):
985 default = i.default()
986 elif i.default is configitems.dynamicdefault:
987 default = b'<DYNAMIC>'
988 else:
989 default = i.default
990 yield section, i.name, default
991
992 def _walk_config(self, untrusted):
952 cfg = self._data(untrusted) 993 cfg = self._data(untrusted)
953 for section in cfg.sections(): 994 for section in cfg.sections():
954 for name, value in self.configitems(section, untrusted): 995 for name, value in self.configitems(section, untrusted):
955 yield section, name, value 996 yield section, name, value
956 997