Show More
@@ -811,6 +811,9 b" coreconfigitem('smtp', 'username'," | |||||
811 | coreconfigitem('sparse', 'missingwarning', |
|
811 | coreconfigitem('sparse', 'missingwarning', | |
812 | default=True, |
|
812 | default=True, | |
813 | ) |
|
813 | ) | |
|
814 | coreconfigitem('subrepos', 'allowed', | |||
|
815 | default=dynamicdefault, # to make backporting simpler | |||
|
816 | ) | |||
814 | coreconfigitem('templates', '.*', |
|
817 | coreconfigitem('templates', '.*', | |
815 | default=None, |
|
818 | default=None, | |
816 | generic=True, |
|
819 | generic=True, |
@@ -1893,6 +1893,19 b' rewrite rules are then applied on the fu' | |||||
1893 | doesn't match the full path, an attempt is made to apply it on the |
|
1893 | doesn't match the full path, an attempt is made to apply it on the | |
1894 | relative path alone. The rules are applied in definition order. |
|
1894 | relative path alone. The rules are applied in definition order. | |
1895 |
|
1895 | |||
|
1896 | ``subrepos`` | |||
|
1897 | ------------ | |||
|
1898 | ||||
|
1899 | This section contains options that control the behavior of the | |||
|
1900 | subrepositories feature. See also :hg:`help subrepos`. | |||
|
1901 | ||||
|
1902 | ``allowed`` | |||
|
1903 | Whether subrepository operation in the working directory is allowed. | |||
|
1904 | ||||
|
1905 | When disabled, any commands including :hg:`update` will fail if | |||
|
1906 | subrepositories are involved. | |||
|
1907 | (default: True) | |||
|
1908 | ||||
1896 | ``templatealias`` |
|
1909 | ``templatealias`` | |
1897 | ----------------- |
|
1910 | ----------------- | |
1898 |
|
1911 |
@@ -365,6 +365,13 b' def _auditsubrepopath(repo, path):' | |||||
365 | if repo.wvfs.islink(path): |
|
365 | if repo.wvfs.islink(path): | |
366 | raise error.Abort(_("subrepo '%s' traverses symbolic link") % path) |
|
366 | raise error.Abort(_("subrepo '%s' traverses symbolic link") % path) | |
367 |
|
367 | |||
|
368 | def _checktype(ui, kind): | |||
|
369 | if not ui.configbool('subrepos', 'allowed', True): | |||
|
370 | raise error.Abort(_("subrepo not allowed"), | |||
|
371 | hint=_("see 'hg help config.subrepos' for details")) | |||
|
372 | if kind not in types: | |||
|
373 | raise error.Abort(_('unknown subrepo type %s') % kind) | |||
|
374 | ||||
368 | def subrepo(ctx, path, allowwdir=False, allowcreate=True): |
|
375 | def subrepo(ctx, path, allowwdir=False, allowcreate=True): | |
369 | """return instance of the right subrepo class for subrepo in path""" |
|
376 | """return instance of the right subrepo class for subrepo in path""" | |
370 | # subrepo inherently violates our import layering rules |
|
377 | # subrepo inherently violates our import layering rules | |
@@ -375,10 +382,10 b' def subrepo(ctx, path, allowwdir=False, ' | |||||
375 | from . import hg as h |
|
382 | from . import hg as h | |
376 | hg = h |
|
383 | hg = h | |
377 |
|
384 | |||
378 |
|
|
385 | repo = ctx.repo() | |
|
386 | _auditsubrepopath(repo, path) | |||
379 | state = ctx.substate[path] |
|
387 | state = ctx.substate[path] | |
380 | if state[2] not in types: |
|
388 | _checktype(repo.ui, state[2]) | |
381 | raise error.Abort(_('unknown subrepo type %s') % state[2]) |
|
|||
382 | if allowwdir: |
|
389 | if allowwdir: | |
383 | state = (state[0], ctx.subrev(path), state[2]) |
|
390 | state = (state[0], ctx.subrev(path), state[2]) | |
384 | return types[state[2]](ctx, path, state[:2], allowcreate) |
|
391 | return types[state[2]](ctx, path, state[:2], allowcreate) | |
@@ -393,10 +400,10 b' def nullsubrepo(ctx, path, pctx):' | |||||
393 | from . import hg as h |
|
400 | from . import hg as h | |
394 | hg = h |
|
401 | hg = h | |
395 |
|
402 | |||
396 |
|
|
403 | repo = ctx.repo() | |
|
404 | _auditsubrepopath(repo, path) | |||
397 | state = ctx.substate[path] |
|
405 | state = ctx.substate[path] | |
398 | if state[2] not in types: |
|
406 | _checktype(repo.ui, state[2]) | |
399 | raise error.Abort(_('unknown subrepo type %s') % state[2]) |
|
|||
400 | subrev = '' |
|
407 | subrev = '' | |
401 | if state[2] == 'hg': |
|
408 | if state[2] == 'hg': | |
402 | subrev = "0" * 40 |
|
409 | subrev = "0" * 40 |
@@ -86,9 +86,29 b' clone root' | |||||
86 | path s |
|
86 | path s | |
87 | source ../gitroot |
|
87 | source ../gitroot | |
88 | revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a |
|
88 | revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a | |
|
89 | $ cd .. | |||
|
90 | ||||
|
91 | clone with subrepo disabled (update should fail) | |||
|
92 | ||||
|
93 | $ hg clone t -U tc2 --config subrepos.allowed=false | |||
|
94 | $ hg update -R tc2 --config subrepos.allowed=false | |||
|
95 | abort: subrepo not allowed | |||
|
96 | (see 'hg help config.subrepos' for details) | |||
|
97 | [255] | |||
|
98 | $ ls tc2 | |||
|
99 | a | |||
|
100 | ||||
|
101 | $ hg clone t tc3 --config subrepos.allowed=false | |||
|
102 | updating to branch default | |||
|
103 | abort: subrepo not allowed | |||
|
104 | (see 'hg help config.subrepos' for details) | |||
|
105 | [255] | |||
|
106 | $ ls tc3 | |||
|
107 | a | |||
89 |
|
108 | |||
90 | update to previous substate |
|
109 | update to previous substate | |
91 |
|
110 | |||
|
111 | $ cd tc | |||
92 | $ hg update 1 -q |
|
112 | $ hg update 1 -q | |
93 | $ cat s/g |
|
113 | $ cat s/g | |
94 | g |
|
114 | g |
@@ -484,9 +484,29 b' clone' | |||||
484 | path t |
|
484 | path t | |
485 | source t |
|
485 | source t | |
486 | revision 20a0db6fbf6c3d2836e6519a642ae929bfc67c0e |
|
486 | revision 20a0db6fbf6c3d2836e6519a642ae929bfc67c0e | |
|
487 | $ cd .. | |||
|
488 | ||||
|
489 | clone with subrepo disabled (update should fail) | |||
|
490 | ||||
|
491 | $ hg clone t -U tc2 --config subrepos.allowed=false | |||
|
492 | $ hg update -R tc2 --config subrepos.allowed=false | |||
|
493 | abort: subrepo not allowed | |||
|
494 | (see 'hg help config.subrepos' for details) | |||
|
495 | [255] | |||
|
496 | $ ls tc2 | |||
|
497 | a | |||
|
498 | ||||
|
499 | $ hg clone t tc3 --config subrepos.allowed=false | |||
|
500 | updating to branch default | |||
|
501 | abort: subrepo not allowed | |||
|
502 | (see 'hg help config.subrepos' for details) | |||
|
503 | [255] | |||
|
504 | $ ls tc3 | |||
|
505 | a | |||
487 |
|
506 | |||
488 | push |
|
507 | push | |
489 |
|
508 | |||
|
509 | $ cd tc | |||
490 | $ echo bah > t/t |
|
510 | $ echo bah > t/t | |
491 | $ hg ci -m11 |
|
511 | $ hg ci -m11 | |
492 | committing subrepository t |
|
512 | committing subrepository t |
General Comments 0
You need to be logged in to leave comments.
Login now