mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
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'
This commit is contained in:
parent
f864544d81
commit
9752ef714d
@ -1900,11 +1900,12 @@ This section contains options that control the behavior of the
|
|||||||
subrepositories feature. See also :hg:`help subrepos`.
|
subrepositories feature. See also :hg:`help subrepos`.
|
||||||
|
|
||||||
``allowed``
|
``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.
|
subrepositories are involved.
|
||||||
(default: True)
|
(default: `hg, git, svn`)
|
||||||
|
|
||||||
``templatealias``
|
``templatealias``
|
||||||
-----------------
|
-----------------
|
||||||
|
@ -366,8 +366,8 @@ def _auditsubrepopath(repo, path):
|
|||||||
raise error.Abort(_("subrepo '%s' traverses symbolic link") % path)
|
raise error.Abort(_("subrepo '%s' traverses symbolic link") % path)
|
||||||
|
|
||||||
def _checktype(ui, kind):
|
def _checktype(ui, kind):
|
||||||
if not ui.configbool('subrepos', 'allowed', True):
|
if kind not in ui.configlist('subrepos', 'allowed', ['hg', 'git', 'svn']):
|
||||||
raise error.Abort(_("subrepo not allowed"),
|
raise error.Abort(_("subrepo type %s not allowed") % kind,
|
||||||
hint=_("see 'hg help config.subrepos' for details"))
|
hint=_("see 'hg help config.subrepos' for details"))
|
||||||
if kind not in types:
|
if kind not in types:
|
||||||
raise error.Abort(_('unknown subrepo type %s') % kind)
|
raise error.Abort(_('unknown subrepo type %s') % kind)
|
||||||
|
@ -90,22 +90,30 @@ clone root
|
|||||||
|
|
||||||
clone with subrepo disabled (update should fail)
|
clone with subrepo disabled (update should fail)
|
||||||
|
|
||||||
$ hg clone t -U tc2 --config subrepos.allowed=false
|
$ hg clone t -U tc2 --config subrepos.allowed=
|
||||||
$ hg update -R tc2 --config subrepos.allowed=false
|
$ hg update -R tc2 --config subrepos.allowed=
|
||||||
abort: subrepo not allowed
|
abort: subrepo type git not allowed
|
||||||
(see 'hg help config.subrepos' for details)
|
(see 'hg help config.subrepos' for details)
|
||||||
[255]
|
[255]
|
||||||
$ ls tc2
|
$ ls tc2
|
||||||
a
|
a
|
||||||
|
|
||||||
$ hg clone t tc3 --config subrepos.allowed=false
|
$ hg clone t tc3 --config subrepos.allowed=
|
||||||
updating to branch default
|
updating to branch default
|
||||||
abort: subrepo not allowed
|
abort: subrepo type git not allowed
|
||||||
(see 'hg help config.subrepos' for details)
|
(see 'hg help config.subrepos' for details)
|
||||||
[255]
|
[255]
|
||||||
$ ls tc3
|
$ ls tc3
|
||||||
a
|
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
|
update to previous substate
|
||||||
|
|
||||||
$ cd tc
|
$ cd tc
|
||||||
|
@ -488,22 +488,30 @@ clone
|
|||||||
|
|
||||||
clone with subrepo disabled (update should fail)
|
clone with subrepo disabled (update should fail)
|
||||||
|
|
||||||
$ hg clone t -U tc2 --config subrepos.allowed=false
|
$ hg clone t -U tc2 --config subrepos.allowed=
|
||||||
$ hg update -R tc2 --config subrepos.allowed=false
|
$ hg update -R tc2 --config subrepos.allowed=
|
||||||
abort: subrepo not allowed
|
abort: subrepo type hg not allowed
|
||||||
(see 'hg help config.subrepos' for details)
|
(see 'hg help config.subrepos' for details)
|
||||||
[255]
|
[255]
|
||||||
$ ls tc2
|
$ ls tc2
|
||||||
a
|
a
|
||||||
|
|
||||||
$ hg clone t tc3 --config subrepos.allowed=false
|
$ hg clone t tc3 --config subrepos.allowed=
|
||||||
updating to branch default
|
updating to branch default
|
||||||
abort: subrepo not allowed
|
abort: subrepo type hg not allowed
|
||||||
(see 'hg help config.subrepos' for details)
|
(see 'hg help config.subrepos' for details)
|
||||||
[255]
|
[255]
|
||||||
$ ls tc3
|
$ ls tc3
|
||||||
a
|
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
|
push
|
||||||
|
|
||||||
$ cd tc
|
$ cd tc
|
||||||
|
Loading…
Reference in New Issue
Block a user