Is there an ignore-on-commit option in mercurial?

Is there a way to ignore changes in some commit files using mercurial?

I have a specific situation where we have a default oracle tnsnames.ora file that points to 127.0.0.1, but some developers will modify it to point to other systems, but we don’t want to change the default file.

In subversive work, I simply added this to the list of changes in-ignore. Is there any way to do this in mercurial?

+38
mercurial hgignore
May 19 '09 at 19:18
source share
4 answers

If the files you want to omit from the "hg commit" command are already "tracked", you should use the -X option. The sample passed to -X is quite flexible, allowing you to run, for example:

% hg stat A etc/foo.conf M src/bar.c M lib/libbar/loader.c % hg commit -X '**.conf' 

to avoid committing any file with a .conf extension, no matter how deep it is in the source tree. In the workspace shown above, this would fix "src / bar.c" and "lib / libbar / loader.c", but not "etc / foo.conf".

To exclude multiple file name patterns, use several -X options, for example:

 % hg commit -X '**.conf' -X '**.sh' 
+48
May 22, '09 at 1:16
source share

Traditionally, this is not solved by the version of the file itself, but by the version of its copy as a template for other users.

So, you would hg mv tnsnames.ora tnsnames.ora-template , then commit, then make a direct copy of the tnsnames.ora-template file system to tnsnames.ora and add tnsnames.ora to the .hgignore file.

Subsequent changes to the template will still be pushed out, but they will not actually change the working environment unless someone copies the template to the actual file.

+21
May 21, '09 at 3:18
source share

You could do an alias something like "hg commit -X excluded_file.ext". I have never used mercurial, so I just go to the man page here.

+1
May 19 '09 at 19:29
source share

Look for the .hgignore file in the Mercurial documentation.

Here is an example of an ignore file.

  # use glob syntax. syntax: glob *.elc *.pyc *~ # switch to regexp syntax. syntax: regexp ^\.pc/ 
-2
May 19 '09 at 19:21
source share



All Articles