开发者

Excluding project configuration files from commits in Mercurial

开发者 https://www.devze.com 2022-12-21 17:46 出处:网络
I have a project that requires some configuration files. I want to keep the default configuration filse in the r开发者_运维百科epository. However, I want don\'t want to have to specify the -X flag for

I have a project that requires some configuration files. I want to keep the default configuration filse in the r开发者_运维百科epository. However, I want don't want to have to specify the -X flag for every commit I do. Is there a standard way to mark a set of revisioned files as permanently excluded from commits?


Interesting question, I hope you get a better answer. Faced similar problems, I have done the following:

  • Rename the configuration files, so that for example, instead of noweb.cfg I have noweb.cfg.default. This file changes seldom and is kept under revision control.

  • The actual configuration file, noweb.cfg, may change frequently but is put in the .hgignore file so it is never committed.

  • At need I have a special Makefile target that rebuilds *.cfg from *.cfg.default.

This solution is not ideal because changes in the .cfg files are lost when the .cfg.default changes. In principle you could tackle this issue with diff3 or some more sophisticated merge tool, but I have never been energetic enough to go there.


You could use the (much maligned) defaults section in your .hgrc:

  [defaults]
  commit = -X thefileyouwanttoexclude

If you can retrain your fingers the preferred way to do that is with an alias instead:

 [alias]
  cmt = commit -X thefileyouwanttoexclude

then you start using hg cmt instead of commit.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号