Mercurial 中的版本控制扩展配置
通常,我会通过将以下内容添加到 .hg/hgrc
来启用扩展:
[extensions]
hgext.win32text=
[encode]
** = cleverencode:
[decode]
** = cleverdecode:
但是,我希望此配置进行版本控制,即存储库的一部分,以便其他任何人(同事,构建机器)克隆存储库。 请注意,克隆存储库的任何人都不需要执行任何操作来启用这些扩展。
从 文档 看来这是不可能的,但是有人知道任何巧妙的技巧吗?可以帮我吗?
Normally, I would enable extensions by adding the following to .hg/hgrc
:
[extensions]
hgext.win32text=
[encode]
** = cleverencode:
[decode]
** = cleverdecode:
However, I want this configuration to be versioned, i.e. part of the repository, so that it is enabled for anyone else (coworkers, build machines) cloning the repository. Note that whomsoever clones the repository should not be required to do anything to enable these extensions.
It appears it is not possible from the documentation, but does anyone know any neat tricks that can help me here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您希望 Mercurial 在克隆存储库时自动执行某些操作(更新挂钩或配置)。 文档说这是不可能的,并给出了一些很好的理由:
很明显,mercurial 本身并不能解决你的问题。 您明确表示您只想用善变来解决您的问题,所以答案是:您所要求的是不可能的。
解决问题的唯一方法是,所有用户都必须至少运行/安装一次给定脚本来执行您想要的操作,例如安装正确的挂钩。
如果您想聪明一点:
有点复杂,但这是我能想象到的最接近您的要求:
You want mercurial to do something automatically when you clone a repo (update the hooks or config). Documentation says it is not possible and gives some very good reasons:
So clearly, mercurial itself won't solve your problem. You clearly state that you want nothing but mercurial to solve your problem, so the answer is: what you are asking is not possible.
The only way to solve your problem is that all your users will have to run/install at least once a given script that perform the actions you want, something like installing the right hooks.
If you want to be clever about this:
A bit complicated, but that's the closest I can imagine to your requirements:
Mercurial 的当前开发版本(将于 7 月 1 日作为 Mercurial 1.3 发布)在其配置文件中支持
%include
指令。这意味着您可以要求人们将其放入
.hg/hgrc
中。 完成此操作后,您可以通过向common-hgrc
提交更改来有效控制其 Mercurial 设置。 当他们拉取更改时,新设置将生效。请注意,这很危险:任何可以让您将更改拉入存储库的人现在都可以将任意挂钩插入到
common-hgrc
中,并且您将在下一个 Mercurial 命令上执行它们(甚至是“安全”命令) “命令行hg status
)。The current development version of Mercurial (to be released as Mercurial 1.3 on July 1st) supports a
%include
directive in its configuration files.That means that you can ask people to put
into
.hg/hgrc
. Having done that, you can then effectively control their Mercurial settings by committing changes tocommon-hgrc
. When they pull the change, the new settings will take effect.Do note, that this is dangerous: anybody who can get you to pull changes into your repository can now insert arbitrary hooks into
common-hgrc
and you will execute them on the next Mercurial command (even a "safe" command linehg status
).您也许可以通过 ProjRC 扩展 解决该问题。
“此扩展使 Mercurial 查找并解析 .hg/projrc 以获取其他配置设置。 文件在克隆和拉取时传输(但从不在推送时传输)”
You might be able to solve that problem via the ProjRC extension.
“This extension makes Mercurial look for and parse .hg/projrc for additional configuration settings. The file is transferred on clone and on pull (but never on push)”
创建一个从
.hg/hgrc
到customhg/hgrc
的链接,以便对其进行版本控制怎么样? 然后您需要创建一些钩子将其复制回.hg/hgrc
- 例如在每次更新后。What about creating a link from
.hg/hgrc
to e.g.customhg/hgrc
so that it gets versioned. Then you need to create some hook that copies it back to.hg/hgrc
- e.g. after each update.