Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > 41c8e355a9bd3d5f7cc6c68d108cb600 > files > 5

mercurial-4.1.3-1.2.mga6.src.rpm

# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1509886138 -32400
#      Sun Nov 05 21:48:58 2017 +0900
# Branch stable
# Node ID 828cf35f1de6b5d8512fc332ad194a79592b0d04
# Parent  5e27afeddaee6754de902c5615afded32c6d87a3
subrepo: extend config option to disable subrepos by type (SEC)

This allows us to minimize the behavior change introduced by the next patch.

I have no idea which config style is preferred in UX POV, but I decided to
get things done.

 a) list: 'allowed = hg, git, svn'
 b) sub option: 'allowed.hg = True' or 'allowed:hg = True'
 c) per-type action: 'hg = allow', 'git = abort'

---
 mercurial/help/config.txt |    7 ++++---
 mercurial/subrepo.py      |    4 ++--
 tests/test-subrepo-git.t  |   18 +++++++++++++-----
 tests/test-subrepo.t      |   18 +++++++++++++-----
 4 files changed, 32 insertions(+), 15 deletions(-)

--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1786,11 +1786,12 @@ This section contains options that contr
 subrepositories feature. See also :hg:`help subrepos`.
 
 ``allowed``
-    Whether subrepository operation in the working directory is allowed.
+    List of subrepository types (hg, git, svn) allowed in the working
+    directory.
 
-    When disabled, any commands including :hg:`update` will fail if
+    When disallowed, any commands including :hg:`update` will fail if
     subrepositories are involved.
-    (default: True)
+    (default: `hg, git, svn`)
 
 ``templatealias``
 -----------------
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -366,8 +366,8 @@ def _auditsubrepopath(repo, path):
         raise error.Abort(_("subrepo '%s' traverses symbolic link") % path)
 
 def _checktype(ui, kind):
-    if not ui.configbool('subrepos', 'allowed', True):
-        raise error.Abort(_("subrepo not allowed"),
+    if kind not in ui.configlist('subrepos', 'allowed', ['hg', 'git', 'svn']):
+        raise error.Abort(_("subrepo type %s not allowed") % kind,
                           hint=_("see 'hg help config.subrepos' for details"))
     if kind not in types:
         raise error.Abort(_('unknown subrepo type %s') % kind)
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -85,22 +85,30 @@ clone root
 
 clone with subrepo disabled (update should fail)
 
-  $ hg clone t -U tc2 --config subrepos.allowed=false
-  $ hg update -R tc2 --config subrepos.allowed=false
-  abort: subrepo not allowed
+  $ hg clone t -U tc2 --config subrepos.allowed=
+  $ hg update -R tc2 --config subrepos.allowed=
+  abort: subrepo type git not allowed
   (see 'hg help config.subrepos' for details)
   [255]
   $ ls tc2
   a
 
-  $ hg clone t tc3 --config subrepos.allowed=false
+  $ hg clone t tc3 --config subrepos.allowed=
   updating to branch default
-  abort: subrepo not allowed
+  abort: subrepo type git not allowed
   (see 'hg help config.subrepos' for details)
   [255]
   $ ls tc3
   a
 
+  $ hg clone t tc4 --config subrepos.allowed=hg
+  updating to branch default
+  abort: subrepo type git not allowed
+  (see 'hg help config.subrepos' for details)
+  [255]
+  $ ls tc4
+  a
+
 update to previous substate
 
   $ cd tc
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -488,22 +488,30 @@ clone
 
 clone with subrepo disabled (update should fail)
 
-  $ hg clone t -U tc2 --config subrepos.allowed=false
-  $ hg update -R tc2 --config subrepos.allowed=false
-  abort: subrepo not allowed
+  $ hg clone t -U tc2 --config subrepos.allowed=
+  $ hg update -R tc2 --config subrepos.allowed=
+  abort: subrepo type hg not allowed
   (see 'hg help config.subrepos' for details)
   [255]
   $ ls tc2
   a
 
-  $ hg clone t tc3 --config subrepos.allowed=false
+  $ hg clone t tc3 --config subrepos.allowed=
   updating to branch default
-  abort: subrepo not allowed
+  abort: subrepo type hg not allowed
   (see 'hg help config.subrepos' for details)
   [255]
   $ ls tc3
   a
 
+  $ hg clone t tc4 --config subrepos.allowed=git
+  updating to branch default
+  abort: subrepo type hg not allowed
+  (see 'hg help config.subrepos' for details)
+  [255]
+  $ ls tc4
+  a
+
 push
 
   $ cd tc