【问题标题】:Is it possible to check in a portion of mercurial hgrc file into the repo? Specifically, the [path] section是否可以将部分 mercurial hgrc 文件签入到 repo 中?具体来说, [path] 部分
【发布时间】:2013-11-21 09:43:50
【问题描述】:

在对 google 和 stack 做了一些研究之后,似乎不可能将 hgrc 文件签入到 repo 中,出于各种安全原因,这很有意义。

但是,我有一个有趣的设置,我想知道是否有人知道如何使这更容易。

具体来说,我们经营着大量的电子商务商店,其中的模板是基于基础存储库构建的,并且每个商店也有自己的存储库(继承自基础存储库)。

我们也有许多开发环境,因此为了更容易,我们在 hgrc 中大量使用 [path] 指令。

这是我们的设置示例:

假设我们有以下商店模板存储库:electronic_store、clothing_store、toy_store,以及一个名为 base 的基本模板

我们还有以下环境:paris、london 和 live

因此,在每个商店的 hgrc 中,我们有以下内容:

;inside hgrc for electronic_store
[path]
default = kiln://instances/live/electronic_store
paris = kiln://instances/paris/electronic_store
london = kiln://instances/london/electronic_store
live = kiln://instances/live/electronic_store
base = kiln://instances/live/base

;inside hgrc for clothing_store
[path]
default = kiln://instances/live/clothing_store
paris = kiln://instances/paris/clothing_store
london = kiln://instances/london/clothing_store
live = kiln://instances/live/clothing_store
base = kiln://instances/live/base

这使得在任何环境中都可以轻松进行 hg pull base、hg push/pull paris、hg push/pull live 等

但是,我们经常关闭环境并打开新环境,然后不仅在每个店面(我们希望这样做)而且在每个环境中更新所有存储库的 hgrc 都会变得非常乏味。由于未跟踪 hgrc,因此无法像我们预期的那样通过简单的拉/推来同步这些更改。

我们也不能将这些添加到我们的全局 .hgrc 文件中,因为虽然路径名称相同,但它们会推送/拉取到各自的存储库(即,电子商店上的 hg push paris 与服装商店上的 hg push paris 是不同的存储库)

有什么方法可以使 hgrc 的 [path] 部分在 repo 中可跟踪?或者,如果失败了,根据我们目前的设置,是否有任何其他建议可以更轻松地管理我所描述的存储库?

提前致谢。

【问题讨论】:

    标签: version-control mercurial hgrc


    【解决方案1】:

    正如Ry4an 所说的here in StackOverflow,有一个不常用的%include 指令。诀窍可能是:

    ./.hg/hgrc 中,通常的配置加上一行包含来自工作目录的hgrc 文件:

    [paths]
    %include ../hgrc.tracked.paths 
    

    ./hgrc.tracked.paths 中由 Mercurial 版本化的路径:

    [paths]
    default = kiln://instances/live/clothing_store
    paris = kiln://instances/paris/clothing_store
    london = kiln://instances/london/clothing_store
    ...
    

    所以hg add hgrc.tracked.paths 将开始版本控制和共享文件。

    【讨论】:

    • 完美,正是我想要的。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-06
    • 2018-12-15
    • 2023-03-11
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多