Mercurial: 启用 git 子仓库功能

15

最近,此行为已默认禁用。该消息提示您检查帮助页面,但并不实用,至少对我没有帮助。

 "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)

我假设是将以下内容添加到项目的hgrc文件中:

[subrepos]
git:allowed

但是它会出现解析错误。有人知道正确的格式吗?而且,为什么他们决定禁用它?每次我检出这个项目都要进行这个更改吗?


1
语法应为 git:allowed = true。我没有尝试过,但是与例如 [diff] 部分设置 git = true 相比较。如果您不关心安全问题,可以在个人的 .hgrc 中进行设置。 - torek
3个回答

15
在你的.hgrc文件中,你必须添加以下内容:
[subrepos]
git:allowed = true

1
这也可以通过编辑.hg/hgrc文件为单个存储库启用。 - Petr

4

我在 ~/.hgrc 配置文件中使用了以下内容,并验证了allowedgit:allowed都能按预期启用和禁用功能。

[subrepos]
allowed = True
hg:allowed = True
git:allowed = True
svn:allowed = True

这是最好的答案。 - Marc Tamsky

1
在Debian 8的docker容器中,Mercurial版本为3.1.2,在将repos和subrepos迁移到Phabricator后,Mercurial停止工作。它报告如下:
abort: subrepo type git not allowed
(see 'hg help config.subrepos' for details)

首先,查看帮助只需

这样

hg help subrepos

但这并不实用。上面建议的.hgrc语法对我们没有起作用。然而,以下语法可以:

[subrepos]
allowed = hg git

这对我们公司大有帮助。非常感谢! - dddJewelsbbb

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接