3

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.

Community
  • 1
  • 1
Jeremy Edwards
  • 14,620
  • 17
  • 74
  • 99
  • also http://stackoverflow.com/questions/1378953/mercurial-workflow-question-how-to-handle-config-files – jk. Oct 20 '11 at 16:44

5 Answers5

3

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.

Laurens Holst
  • 20,156
  • 2
  • 29
  • 33
2

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.

Community
  • 1
  • 1
kostja
  • 60,521
  • 48
  • 179
  • 224
0

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).

Cat Plus Plus
  • 125,936
  • 27
  • 200
  • 224
0

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).

Amber
  • 507,862
  • 82
  • 626
  • 550
  • I don't know anything about Mercurial hooks or the Python language. Is there an example of what I want somewhere that I can use? – Jeremy Edwards Oct 20 '11 at 14:19
  • You don't need to know Python to write a hook (they can be any arbitrary command that's executable, so you could make one as trivial as a bash script). There are a few examples of shell command hooks here: http://mercurial.selenic.com/wiki/UsefulHooks – Amber Oct 20 '11 at 14:26
0

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.

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110