Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
mercurial
hg-subrepo-bsc1071715-fix03.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File hg-subrepo-bsc1071715-fix03.patch of Package mercurial
# HG changeset patch # User Yuya Nishihara <yuya@tcha.org> # Date 1509884527 -32400 # Sun Nov 05 21:22:07 2017 +0900 # Branch stable # Node ID 5e27afeddaee6754de902c5615afded32c6d87a3 # Parent 071cbeba421217d722a69a5d614ec934684d62d5 subrepo: add config option to reject any subrepo operations (SEC) This is an alternative workaround for the issue5730. Perhaps this is the simplest way of disabling subrepo operations. It does nothing clever, but just aborts if Mercurial starts accessing to a subrepo. I think Greg's patch is more useful since it allows us to at least check out the parent repository. However, that would be confusing if the default is flipped to checkout=False and subrepos are silently ignored. I don't like the config name 'allowed', but I couldn't get any better name. --- mercurial/help/config.txt | 13 +++++++++++++ mercurial/subrepo.py | 15 +++++++++++---- tests/test-subrepo-git.t | 20 ++++++++++++++++++++ tests/test-subrepo.t | 20 ++++++++++++++++++++ 4 files changed, 64 insertions(+), 4 deletions(-) --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -1102,6 +1102,19 @@ Relative subrepository paths are first m rewrite rules are then applied on the full (absolute) path. The rules are applied in definition order. +``subrepos`` +------------ + +This section contains options that control the behavior of the +subrepositories feature. See also :hg:`help subrepos`. + +``allowed`` + Whether subrepository operation in the working directory is allowed. + + When disabled, any commands including :hg:`update` will fail if + subrepositories are involved. + (default: True) + ``trusted`` ----------- --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -340,7 +340,14 @@ def _auditsubrepopath(repo, path): if repo.wvfs.islink(path): raise error.Abort(_("subrepo '%s' traverses symbolic link") % path) -def subrepo(ctx, path): +def _checktype(ui, kind): + if not ui.configbool('subrepos', 'allowed', True): + raise error.Abort(_("subrepo not allowed"), + hint=_("see 'hg help config.subrepos' for details")) + if kind not in types: + raise error.Abort(_('unknown subrepo type %s') % kind) + +def subrepo(ctx, path, allowwdir=False, allowcreate=True): """return instance of the right subrepo class for subrepo in path""" # subrepo inherently violates our import layering rules # because it wants to make repo objects from deep inside the stack @@ -350,10 +357,10 @@ def subrepo(ctx, path): import hg as h hg = h - _auditsubrepopath(ctx._repo, path) + repo = ctx._repo + _auditsubrepopath(repo, path) state = ctx.substate[path] - if state[2] not in types: - raise util.Abort(_('unknown subrepo type %s') % state[2]) + _checktype(repo.ui, state[2]) return types[state[2]](ctx, path, state[:2]) # subrepo classes need to implement the following abstract class: --- a/tests/test-subrepo-git.t +++ b/tests/test-subrepo-git.t @@ -80,9 +80,29 @@ clone root path s source ../gitroot revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a + $ cd .. + +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 + (see 'hg help config.subrepos' for details) + [255] + $ ls tc2 + a + + $ hg clone t tc3 --config subrepos.allowed=false + updating to branch default + abort: subrepo not allowed + (see 'hg help config.subrepos' for details) + [255] + $ ls tc3 + a update to previous substate + $ cd tc $ hg update 1 -q $ cat s/g g --- a/tests/test-subrepo.t +++ b/tests/test-subrepo.t @@ -284,9 +284,29 @@ clone path t source t revision 20a0db6fbf6c3d2836e6519a642ae929bfc67c0e + $ cd .. + +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 + (see 'hg help config.subrepos' for details) + [255] + $ ls tc2 + a + + $ hg clone t tc3 --config subrepos.allowed=false + updating to branch default + abort: subrepo not allowed + (see 'hg help config.subrepos' for details) + [255] + $ ls tc3 + a push + $ cd tc $ echo bah > t/t $ hg ci -m11 committing subrepository t
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor