Mercurial 防止文件更改

发布于 2024-12-11 04:15:32 字数 408 浏览 0 评论 0原文

可能的重复:
Mercurial:如何忽略对跟踪文件的更改

我在一个使用 Mercurial 的团队工作,我们有一个已签入且稳定的配置文件。

由于它是一个配置文件,一些团队成员需要对其进行更改才能使软件在他们的计算机上运行,​​但我想防止这些更改在签入时进入存储库。

我该如何做到这一点?

我希望默认配置文件位于存储库中,并且用户所做的更改在提交时被忽略。

Possible Duplicate:
Mercurial: How to ignore changes to a tracked file

I work on a team that uses Mercurial and we have a config file that is checked in and is stable.

Being that it's a config file, some team members need to make changes to it to have the software work on their machine but I want to prevent those changes from making it into the repository on checkin.

How can I do this?

I want the default config file to be in the repository and user made changes to be ignored on commit.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

段念尘 2024-12-18 04:15:32

一般模式是从存储库中删除 config 文件并将其添加到 .hgignore,而不是提供一个 config.example 文件用户必须复制到config并进行自定义。如果您想使项目设置尽可能简单,则可以通过构建脚本完成此复制。

另请参阅 kostja 发布的链接。

The general pattern is to remove the config file from the repository and add it to .hgignore, and instead to provide a config.example file which users have to copy to config and customize. This copying can be done by the build script if you want to keep project set-up as simple as possible.

See also the links posted by kostja.

伴随着你 2024-12-18 04:15:32

您可能想看看类似的问题(回答 git 和 svn 的类似问题):Git - 提交计算机特定配置文件如何实用地对配置文件进行版本控制?

请注意,他们不会直接回答您的问题,而是提供一些规避该问题的最佳实践。

在当前的项目中,我们决定支持在版本控制下使用模板(例如 template.properties),并修改它们以供本地使用,例如(local.properties)并忽略修改过的文件。这是更稳健的方法。

在另一个项目中,我们采取了不同的方法,每个开发人员都有一个单独的文件(
{activeDirectoryLogin}.properties})。根据当前用户自动选择适当的文件。这种方法有其缺点,幸运的是我们可以忽略这些缺点,因为在项目期间我们有一个由 5 名同地开发人员组成的相当小而稳定的团队。好处是,开发人员了解其他人的偏好,并且可以快速重现任何可能的问题。另外,可以在不同的系统上轻松评估这些设置。

You may want to take a look at similar questions (anwering similar questions for git and svn) : Git - Committing Machine Specific Configuration Files and How to version control config files pragmatically?.

Please note, they do not answer your question directly, but provide some best practices for circumventing the issue.

In a current project, we decided in favor of having templates under version control (like template.properties) and modifying them for local use like (local.properties) and ignoring the modified files. This is the more robust approach.

In another project we took a different approach, having a separate file per developer (
{activeDirectoryLogin}.properties}). The appropriate file is selected automatically based on the current user. This approach has its disadvantages, which we could luckily neglect, because we had a rather small and stable team of 5 co-located developers for the duration of the project. The upside is, that the developers are aware of other's preferences and are can quickly reproduce any possible issues. Plus, the settings can be easily evaluated on different systems.

尘世孤行 2024-12-18 04:15:32

你不能。您不应该跟踪需要在本地副本中更改的文件,而是跟踪模板(或修改您的配置系统以允许本地配置文件覆盖默认配置文件)。

You can't. You should not track files that need to be changed in local copies, track a template instead (or revise your config system to allow for local config file overriding the default one).

在巴黎塔顶看东京樱花 2024-12-18 04:15:32

您需要添加一个挂钩来执行此操作:

http://www.selenic。 com/mercurial/hgrc.5.html#hooks

该钩子可以是服务器端的(这不会阻止提交,但会阻止将该更改推送到服务器端存储库),也可以是客户端的(这可能会阻止提交,但是该钩子必须由每个开发人员在本地安装)。

You would need to add a hook to do this:

http://www.selenic.com/mercurial/hgrc.5.html#hooks

The hook could be either server-side (which wouldn't prevent commit, but would prevent pushing that change to your server-side repository), or client-side (which could prevent the commit, but the hook would have to be installed locally by each developer).

生寂 2024-12-18 04:15:32

您可以将 MQ 扩展与您的需求的小型附加组件一起使用 - 用户特定的更改存储在 mq-patches 中,而不是存储在 permanent-repo 的变更集中。即用户可以更改基本配置,但他的任务是更新MQ中的补丁,而不是像普通变更集那样提交更改。

You can use MQ extension with small add-on to your reqs - user-specific changes are stored inside mq-patches and not inside permanent-repo's changeset. I.e user can change base config, but it's his task to update patch in MQ and not commit changes as ordinary changeset.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文