Exclude project configuration files from commits in Mercurial

I have a project that requires some configuration files. I want to save the default configuration configuration in the repository. However, I want, I don’t want, to specify the -X flag for every commit that I make. Is there a standard way to mark a set of fixed files as permanently excluded from commits?

+6
mercurial
source share
2 answers

An interesting question, I hope you get a better answer. Faced with similar problems, I did the following:

  • Rename the configuration files so that, for example, instead of noweb.cfg , I have noweb.cfg.default . This file is rarely modified and stored under the control of the editorial staff.

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

  • If necessary, I have a special Makefile target that rebuilds *.cfg from *.cfg.default .

This solution is not ideal because changes to .cfg files are lost when you change .cfg.default . You could basically solve this problem with diff3 or an even more sophisticated merge tool, but I was never energetic enough to go there.

+4
source share

You can use the default section .hgrc:

  [defaults] commit = -X thefileyouwanttoexclude 

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

  [alias] cmt = commit -X thefileyouwanttoexclude 

then you start using hg cmt instead of hg cmt .

+3
source share

All Articles