views:

94

answers:

4

I have a file with database settings in my project which I have set to some defaults. The file is tracked by mercurial and checked in. Since this file will be edited with different values various developer machines, is there a way I can tell Mercurial to ignore new changes to this file?

I tried adding the file to the .hgignore file, but since the file is tracked it isn't ignored. This is alright and good in other situations, but I am wondering if there is something I can do here.

+2  A: 

There is no truly automated process, but you can try (as in this SO question) the -X option on hg commit:

% hg stat
M myfile
% hg commit -X 'myfile'

(other solutions might involve shelve or hq)

However, this is not the "right" solution. I would rather recommend versioning:

  • a file template
  • a script able to generate the final file (that you modify but can ignore altogether)
VonC
+1  A: 

Typically you would check in a reference copy of the file and track it then have the developers make a copy of that for local development, you wouldn't really want developers editing the source controlled file for their own environments.

If your configuration system supports it, it's even easier if you can use an override file that simply override values in the reference copy (e.g. the database connection string). That way devs only have to keep a very minimal local set of override values.

Paolo
+2  A: 

Using a file template is definitely the best solution. For example, if you have a database.ini file, commit a database.ini.template file and ignore database.ini in .hgignore

yanjost
This is what I ended up doing :)
Svish
+1  A: 

If you always want to ignore the file, you can add the -X option as a default for commit to your .hg/hgrc configuration file:

[defaults]
commit = -X program.conf
sth