Mercurial: enable git subrepo
Asked Answered
B

3

15

Recently this behavior was disabled by default. The message prompts you to check the help page but it's not helpful, at least it didn't help me.

 "subrepos"
    ----------

    This section contains options that control the behavior of the
    subrepositories feature. See also 'hg help subrepos'.

    Security note: auditing in Mercurial is known to be insufficient to
    prevent clone-time code execution with carefully constructed Git subrepos.
    It is unknown if a similar detect is present in Subversion subrepos. Both
    Git and Subversion subrepos are disabled by default out of security
    concerns. These subrepo types can be enabled using the respective options
    below.

    "allowed"
        Whether subrepositories are allowed in the working directory.

        When false, commands involving subrepositories (like 'hg update') will
        fail for all subrepository types. (default: true)

    "hg:allowed"
        Whether Mercurial subrepositories are allowed in the working
        directory. This option only has an effect if "subrepos.allowed" is
        true. (default: true)

    "git:allowed"
        Whether Git subrepositories are allowed in the working directory. This
        option only has an effect if "subrepos.allowed" is true.

        See the security note above before enabling Git subrepos. (default:
        false)

    "svn:allowed"
        Whether Subversion subrepositories are allowed in the working
        directory. This option only has an effect if "subrepos.allowed" is
        true.

        See the security note above before enabling Subversion subrepos.
        (default: false)

I assumed it was adding the following to the project's hgrc:

[subrepos]
git:allowed

But it gives a parsing error. Does anyone know the right format? And also, why they decided to disable this? Each time I checkout this project I'll have to make this change?

Bernardina answered 30/3, 2018 at 16:31 Comment(1)
The syntax should be git:allowed = true. I have not tried it, but compare to, e.g., section [diff] setting git = true. You can set it in your personal .hgrc if you are not concerned about the security issues.Rappee
S
15

In your .hgrc file, you must add:

[subrepos]
git:allowed = true
Salic answered 3/5, 2018 at 14:55 Comment(1)
This can be also enabled just for a single repository by editing .hg/hgrc.Lecythus
H
4

I used the following in my ~/.hgrc config and verified allowed and git:allowed both enable and disable functionality as expected.

[subrepos]
allowed = True
hg:allowed = True
git:allowed = True
svn:allowed = True
Heavyfooted answered 7/5, 2019 at 18:43 Comment(1)
this is the best answerAstrea
J
1

In a Debian 8 docker container, Mercurial version 3.1.2, mercurial stopped working for us after migrating repos and subrepos to phabricator. It reported:

abort: subrepo type git not allowed
(see 'hg help config.subrepos' for details)

First of all, to see the help it is just

hg help subrepos

But that isn't useful. The syntax suggested above for .hgrc did not work for us. However this did:

[subrepos]
allowed = hg git
Jubilee answered 16/8, 2018 at 19:39 Comment(1)
This helped my company out a lot. Thank you so much!Draughtsman

© 2022 - 2024 — McMap. All rights reserved.