diff mercurial/subrepo.py @ 34989:1a314176da9c stable

subrepo: use per-type config options to enable subrepos We change subrepos.allowed from a list of allowed subrepo types to a combination of a master switch and per-type boolean flag. If the master switch is set, subrepos can be disabled wholesale. If subrepos are globally enabled, then per-type options are consulted. Mercurial repos are enabled by default. Everything else is disabled by default.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 06 Nov 2017 22:32:41 -0800
parents 846942fd6d15
children 5c6b96b832c2 3da4bd50103d
line wrap: on
line diff
--- a/mercurial/subrepo.py	Mon Nov 06 14:56:17 2017 -0500
+++ b/mercurial/subrepo.py	Mon Nov 06 22:32:41 2017 -0800
@@ -365,10 +365,24 @@
     if repo.wvfs.islink(path):
         raise error.Abort(_("subrepo '%s' traverses symbolic link") % path)
 
+SUBREPO_ALLOWED_DEFAULTS = {
+    'hg': True,
+    'git': False,
+    'svn': False,
+}
+
 def _checktype(ui, kind):
-    if kind not in ui.configlist('subrepos', 'allowed', ['hg']):
-        raise error.Abort(_("subrepo type %s not allowed") % kind,
+    # subrepos.allowed is a master kill switch. If disabled, subrepos are
+    # disabled period.
+    if not ui.configbool('subrepos', 'allowed', True):
+        raise error.Abort(_('subrepos not enabled'),
                           hint=_("see 'hg help config.subrepos' for details"))
+
+    default = SUBREPO_ALLOWED_DEFAULTS.get(kind, False)
+    if not ui.configbool('subrepos', '%s:allowed' % kind, default):
+        raise error.Abort(_('%s subrepos not allowed') % kind,
+                          hint=_("see 'hg help config.subrepos' for details"))
+
     if kind not in types:
         raise error.Abort(_('unknown subrepo type %s') % kind)