Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to let Mercurial ignore every thing except *.cs file?

I started a project and added it to Mercurial. But I want to take *.cs file under version control only. So I have to add bin, obj, sln, suo, _resharper folder etc to ignore pattern.

How to let Hg only monitor certain kind of file like white list? How to do that in Subversion?

like image 673
prime23 Avatar asked Aug 27 '09 03:08

prime23


1 Answers

Just add the extensions to your .hgignore file as you come across them:

syntax: glob
*.bin
*.obj

and so on. It's not a lot of work, and it documents to the rest of the world exactly what kind of files you consider unimportant for revision control.

You can even setup a global ignore file, please see the ignore entry in the [ui] section.

Trying to turn the .hgignore upside-down by using negative lookahead regular expressions and other voodoo is (in my opinion) not a good idea. It will almost surely not work and will only lead to confusion. This is because hg matches all prefixes of a give path name against the rules in .hgignore. So a file like

a/b/c.cs

will be ignored if any of

a/b/c.cs
a/b
a

is matched by a rule in your .hgignore file. In particular, this means that you cannot use a negative lookahead expression to have a/b/c.cs not-ignored -- the rule will match a/b or a.

like image 73
Martin Geisler Avatar answered Sep 19 '22 14:09

Martin Geisler