【问题标题】:Make .hgignore in a Mercurial repository available to all subrepos?使 Mercurial 存储库中的 .hgignore 可用于所有子存储库?
【发布时间】:2011-10-17 16:14:32
【问题描述】:

我有一个 Mercurial 存储库,其中包含多个子存储库。是否有可能只在主存储库和子存储库中定义一个通用的 .hgignore 文件(例如忽略对象文件)?

手册中没有足够的信息。用

指定一个 .hgignore 文件
[ui]
ignore = .hgignore

我的主目录中的 .hgrc 也不起作用。

有什么想法吗?

【问题讨论】:

    标签: mercurial hgignore subrepos hgrc


    【解决方案1】:

    每个子存储库中的.hgignore 文件将作为该子存储库的专用文件。然后你可以使用主仓库的 .hgignore 作为主仓库,方法是将其包含在每个子仓库的 hgrc 文件中:

    [ui]
    ignore.main = \absolute\path\to\mainrepo\.hgignore
    

    在你的全局 .hgrc 中执行 ignore = .hgignore 对你不起作用(并且不会在 repo hgrc 中)的原因是,简单的 .hgignore 是一个相对文件路径,它的分辨率为绝对路径取决于调用hg 时使用的当前工作目录。例子:

    • 如果您在\repos\main\ 中并调用hg st,它将寻找\repos\main\.hgignore。如果你调用hg st -R nested 也是一样,因为当前的工作目录还是一样的。
    • 但如果您在 \repos\main\nested\ 中然后调用 hg st,则配置现在将查看 \repos\main\nested\.hgignore

    如果您想在您的主目录中指定一个全局 .hgignore,您需要使用非相对路径(或至少相对较少)来指定它:

    [ui]
    ignore = ~\.hgignore
    

    【讨论】:

    • 我不确定你的第一个要点。如果您调用hg st -R nested,则将使用\repos\main\nested\.hgignore,因为这是nested repo 的工作目录中的.hgignore 文件 - 这可能是您的意思,但它不是那样读的。跨度>
    • @icabod:我没有可以测试的 *nix 机器,但这就是 Windows 的行为方式。如果我在mainnested 中有不同的extra.hgignore 文件并将ignore = extra.hgignore 放入nested\.hg\hgrc,则执行hg sthg st -R nested 都从main\extra.hgignore 中提取。只有当我将cd 转换为nested 时,它才会抓住nested\extra.hgignore。 (对于我的测试,我在 mainnested 中使用了 4 个文件,在忽略文件中分布了 4 个不同的扩展名。)
    • 啊,我想我在尝试时错过了您的部分答案。我的错误:)
    猜你喜欢
    • 1970-01-01
    • 2011-02-21
    • 1970-01-01
    • 1970-01-01
    • 2011-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多