在 Mercurial (hg) 更新时添加钩子
我目前正在开发一个受 mercurial
控制的项目,我希望在更新时获得一个钩子来编辑 .htaccess
fille 以避免更改 APPLICATION_ENV
为了适应“模式”,应用程序应该运行/加载配置/连接到数据库。
我的存储库结构如下:
Main dev repo (ENV : development)
+-- Stable repo (Production version) (ENV : production)
+-- Local dev repo (working version) (ENV : development)
+-- Prototype repo (prototyping repo) (ENV : prototype)
我想要编辑的 .htaccess
部分如下(文件的第一行):
# Application var
SetEnv APPLICATION_ENV development
我不介意运行 python
脚本(或任何其他语言)我正在寻找右钩子以放入 .hg\hgrc
文件
I am currently working on a project which is under mercurial
control and I was looking to get a hook upon update to edit the .htaccess
fille to avoid changing the APPLICATION_ENV
to fit the "mode" the application should run/load configs/connect to the database.
My repository structure goes as follow :
Main dev repo (ENV : development)
+-- Stable repo (Production version) (ENV : production)
+-- Local dev repo (working version) (ENV : development)
+-- Prototype repo (prototyping repo) (ENV : prototype)
The part of the .htaccess
I would like to have edited is the following (the first to lines of the file) :
# Application var
SetEnv APPLICATION_ENV development
I don't mind to run a python
script ( or any other language) I am looking to the right hook to put in the .hg\hgrc
file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是正确的做法,因为这会更改实际文件。您进行的下一次提交实际上会将更改提交到您的存储库。
相反,建议的方法是执行以下操作:
.htaccess.template
.htaccess
添加到.hgignore
文件中,以使 Mercurial 避免在这确保了对实际文件的更改,无论它们是什么,都不会提交到您的存储库。
一些配置系统还支持条件包含,这样您就可以像
如果存在额外的配置文件 X,也加载 X
,然后您将执行以下操作:.hgignore
文件中,这样就不会提交这样的文件到存储库这将确保任何人都可以添加通过添加自己的要包含的文件版本来更改或覆盖默认配置。
That's not the right thing to do, since that would change the actual file. The next commit you make you would actually commit that change to your repository.
Instead, the recommended approach is to do the following:
.htaccess.template
.htaccess
to the.hgignore
file to make Mercurial avoid itThis ensures that changes to the actual file, whatever they may be, will not be committed to your repository.
Some configuration systems also support conditional includes, so that you can something like
if extra config file X exists, load X as well
, and you would then do the following instead:.hgignore
file so that you won't commit such a file to the repositoryThis would ensure that anyone can add to or override the default configuration by adding their own version of that file that will be included.