##// END OF EJS Templates
subrepo: use per-type config options to enable subrepos...
Gregory Szorc -
r34990:1a314176 stable
parent child Browse files
Show More
@@ -814,6 +814,15 b" coreconfigitem('sparse', 'missingwarning"
814 coreconfigitem('subrepos', 'allowed',
814 coreconfigitem('subrepos', 'allowed',
815 default=dynamicdefault, # to make backporting simpler
815 default=dynamicdefault, # to make backporting simpler
816 )
816 )
817 coreconfigitem('subrepos', 'hg:allowed',
818 default=dynamicdefault,
819 )
820 coreconfigitem('subrepos', 'git:allowed',
821 default=dynamicdefault,
822 )
823 coreconfigitem('subrepos', 'svn:allowed',
824 default=dynamicdefault,
825 )
817 coreconfigitem('templates', '.*',
826 coreconfigitem('templates', '.*',
818 default=None,
827 default=None,
819 generic=True,
828 generic=True,
@@ -1899,20 +1899,40 b' relative path alone. The rules are appli'
1899 This section contains options that control the behavior of the
1899 This section contains options that control the behavior of the
1900 subrepositories feature. See also :hg:`help subrepos`.
1900 subrepositories feature. See also :hg:`help subrepos`.
1901
1901
1902 Security note: auditing in Mercurial is known to be insufficient to
1903 prevent clone-time code execution with carefully constructed Git
1904 subrepos. It is unknown if a similar detect is present in Subversion
1905 subrepos. Both Git and Subversion subrepos are disabled by default
1906 out of security concerns. These subrepo types can be enabled using
1907 the respective options below.
1908
1902 ``allowed``
1909 ``allowed``
1903 List of subrepository types (hg, git, svn) allowed in the working
1910 Whether subrepositories are allowed in the working directory.
1904 directory.
1911
1905
1912 When false, commands involving subrepositories (like :hg:`update`)
1906 When disallowed, any commands including :hg:`update` will fail if
1913 will fail for all subrepository types.
1907 subrepositories are involved.
1914 (default: true)
1908
1915
1909 Security note: auditing in Mercurial is known to be insufficient
1916 ``hg:allowed``
1910 to prevent clone-time code execution with carefully constructed
1917 Whether Mercurial subrepositories are allowed in the working
1911 Git subrepos. It is unknown if a similar defect is present in
1918 directory. This option only has an effect if ``subrepos.allowed``
1912 Subversion subrepos, so both are disabled by default out of an
1919 is true.
1913 abundance of caution. Re-enable such subrepos via this setting
1920 (default: true)
1914 with caution.
1921
1915 (default: `hg`)
1922 ``git:allowed``
1923 Whether Git subrepositories are allowed in the working directory.
1924 This option only has an effect if ``subrepos.allowed`` is true.
1925
1926 See the security note above before enabling Git subrepos.
1927 (default: false)
1928
1929 ``svn:allowed``
1930 Whether Subversion subrepositories are allowed in the working
1931 directory. This option only has an effect if ``subrepos.allowed``
1932 is true.
1933
1934 See the security note above before enabling Subversion subrepos.
1935 (default: false)
1916
1936
1917 ``templatealias``
1937 ``templatealias``
1918 -----------------
1938 -----------------
@@ -365,10 +365,24 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 SUBREPO_ALLOWED_DEFAULTS = {
369 'hg': True,
370 'git': False,
371 'svn': False,
372 }
373
368 def _checktype(ui, kind):
374 def _checktype(ui, kind):
369 if kind not in ui.configlist('subrepos', 'allowed', ['hg']):
375 # subrepos.allowed is a master kill switch. If disabled, subrepos are
370 raise error.Abort(_("subrepo type %s not allowed") % kind,
376 # disabled period.
377 if not ui.configbool('subrepos', 'allowed', True):
378 raise error.Abort(_('subrepos not enabled'),
371 hint=_("see 'hg help config.subrepos' for details"))
379 hint=_("see 'hg help config.subrepos' for details"))
380
381 default = SUBREPO_ALLOWED_DEFAULTS.get(kind, False)
382 if not ui.configbool('subrepos', '%s:allowed' % kind, default):
383 raise error.Abort(_('%s subrepos not allowed') % kind,
384 hint=_("see 'hg help config.subrepos' for details"))
385
372 if kind not in types:
386 if kind not in types:
373 raise error.Abort(_('unknown subrepo type %s') % kind)
387 raise error.Abort(_('unknown subrepo type %s') % kind)
374
388
@@ -8,7 +8,7 b''
8 $ echo "convert=" >> $HGRCPATH
8 $ echo "convert=" >> $HGRCPATH
9 $ cat >> $HGRCPATH <<EOF
9 $ cat >> $HGRCPATH <<EOF
10 > [subrepos]
10 > [subrepos]
11 > allowed = hg, git
11 > git:allowed = true
12 > EOF
12 > EOF
13 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
13 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
14 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
14 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
@@ -6,7 +6,8 b''
6 > [diff]
6 > [diff]
7 > nodates = 1
7 > nodates = 1
8 > [subrepos]
8 > [subrepos]
9 > allowed = hg, svn
9 > allowed = true
10 > svn:allowed = true
10 > EOF
11 > EOF
11
12
12 fn to create new repository, and cd into it
13 fn to create new repository, and cd into it
@@ -45,7 +45,7 b' add subrepo clone'
45 git subrepo is disabled by default
45 git subrepo is disabled by default
46
46
47 $ hg commit -m 'new git subrepo'
47 $ hg commit -m 'new git subrepo'
48 abort: subrepo type git not allowed
48 abort: git subrepos not allowed
49 (see 'hg help config.subrepos' for details)
49 (see 'hg help config.subrepos' for details)
50 [255]
50 [255]
51
51
@@ -53,7 +53,7 b' so enable it'
53
53
54 $ cat >> $HGRCPATH <<EOF
54 $ cat >> $HGRCPATH <<EOF
55 > [subrepos]
55 > [subrepos]
56 > allowed = hg, git
56 > git:allowed = true
57 > EOF
57 > EOF
58
58
59 $ hg commit -m 'new git subrepo'
59 $ hg commit -m 'new git subrepo'
@@ -106,30 +106,22 b' clone root'
106
106
107 clone with subrepo disabled (update should fail)
107 clone with subrepo disabled (update should fail)
108
108
109 $ hg clone t -U tc2 --config subrepos.allowed=
109 $ hg clone t -U tc2 --config subrepos.allowed=false
110 $ hg update -R tc2 --config subrepos.allowed=
110 $ hg update -R tc2 --config subrepos.allowed=false
111 abort: subrepo type git not allowed
111 abort: subrepos not enabled
112 (see 'hg help config.subrepos' for details)
112 (see 'hg help config.subrepos' for details)
113 [255]
113 [255]
114 $ ls tc2
114 $ ls tc2
115 a
115 a
116
116
117 $ hg clone t tc3 --config subrepos.allowed=
117 $ hg clone t tc3 --config subrepos.allowed=false
118 updating to branch default
118 updating to branch default
119 abort: subrepo type git not allowed
119 abort: subrepos not enabled
120 (see 'hg help config.subrepos' for details)
120 (see 'hg help config.subrepos' for details)
121 [255]
121 [255]
122 $ ls tc3
122 $ ls tc3
123 a
123 a
124
124
125 $ hg clone t tc4 --config subrepos.allowed=hg
126 updating to branch default
127 abort: subrepo type git not allowed
128 (see 'hg help config.subrepos' for details)
129 [255]
130 $ ls tc4
131 a
132
133 update to previous substate
125 update to previous substate
134
126
135 $ cd tc
127 $ cd tc
@@ -61,7 +61,7 b' add first svn sub with leading whitespac'
61 svn subrepo is disabled by default
61 svn subrepo is disabled by default
62
62
63 $ hg ci -m1
63 $ hg ci -m1
64 abort: subrepo type svn not allowed
64 abort: svn subrepos not allowed
65 (see 'hg help config.subrepos' for details)
65 (see 'hg help config.subrepos' for details)
66 [255]
66 [255]
67
67
@@ -69,7 +69,7 b' so enable it'
69
69
70 $ cat >> $HGRCPATH <<EOF
70 $ cat >> $HGRCPATH <<EOF
71 > [subrepos]
71 > [subrepos]
72 > allowed = hg, svn
72 > svn:allowed = true
73 > EOF
73 > EOF
74
74
75 $ hg ci -m1
75 $ hg ci -m1
@@ -488,30 +488,40 b' clone'
488
488
489 clone with subrepo disabled (update should fail)
489 clone with subrepo disabled (update should fail)
490
490
491 $ hg clone t -U tc2 --config subrepos.allowed=
491 $ hg clone t -U tc2 --config subrepos.allowed=false
492 $ hg update -R tc2 --config subrepos.allowed=
492 $ hg update -R tc2 --config subrepos.allowed=false
493 abort: subrepo type hg not allowed
493 abort: subrepos not enabled
494 (see 'hg help config.subrepos' for details)
494 (see 'hg help config.subrepos' for details)
495 [255]
495 [255]
496 $ ls tc2
496 $ ls tc2
497 a
497 a
498
498
499 $ hg clone t tc3 --config subrepos.allowed=
499 $ hg clone t tc3 --config subrepos.allowed=false
500 updating to branch default
500 updating to branch default
501 abort: subrepo type hg not allowed
501 abort: subrepos not enabled
502 (see 'hg help config.subrepos' for details)
502 (see 'hg help config.subrepos' for details)
503 [255]
503 [255]
504 $ ls tc3
504 $ ls tc3
505 a
505 a
506
506
507 $ hg clone t tc4 --config subrepos.allowed=git
507 And again with just the hg type disabled
508 updating to branch default
508
509 abort: subrepo type hg not allowed
509 $ hg clone t -U tc4 --config subrepos.hg:allowed=false
510 $ hg update -R tc4 --config subrepos.hg:allowed=false
511 abort: hg subrepos not allowed
510 (see 'hg help config.subrepos' for details)
512 (see 'hg help config.subrepos' for details)
511 [255]
513 [255]
512 $ ls tc4
514 $ ls tc4
513 a
515 a
514
516
517 $ hg clone t tc5 --config subrepos.hg:allowed=false
518 updating to branch default
519 abort: hg subrepos not allowed
520 (see 'hg help config.subrepos' for details)
521 [255]
522 $ ls tc5
523 a
524
515 push
525 push
516
526
517 $ cd tc
527 $ cd tc
General Comments 0
You need to be logged in to leave comments. Login now