views:

113

answers:

2

There's a particular file in my repository, libraries/database.php, that I need ignored. However, I can't get the syntax to recognize the file - I've tried **/libraries/**/database.php and libraries/database.php in glob, and ^.libraries/database.php in regex, but neither of them work. What should I do?

+1  A: 
syntax: re
^libraries/database\.php$

That will work.

But, frankly, I've always found the .hgignore syntax to be a little obscure myself. I don't really understand what glob will and won't match.

Omnifarious
As far as I know glob will just try to match the whole line given within the relative (to the repository's root) path. As an example "glob:makefile" will exclude everything that has "makefile" in its path and/or name
Mario
the correct syntax is: syntax: regexp
David
@David - The actual names of the two supported syntaxes are `relre` and `relglob`. But `re` and `regexp` are aliases for `relre`, and `glob` is an alias for `relglob`. This is explicitly so in `ignore.py`. This has been the case since this syntax for `.hgignore` files was introduced in changeset fc3b41570082.
Omnifarious
@Omnifarious - thank you, I will try to be less cocky next time :-) I was stating from the documentation.
David
@Dave - *grin* Well, I noticed the documentation said that, and I knew that `syntax: re` worked, and had worked for me forever. So I did some code spelunking to figure out if it simply worked by accident or if it was supposed to work. It turns out (not too surprisingly) that the documentation is incomplete.
Omnifarious
+1  A: 

From the mercurial QuickStart guide:

"Mercurial will look for a file named .hgignore in the root of your repository which contains a set of glob patterns and regular expressions to ignore in file paths"

is your .hgignore at the right place ?

So

syntax: glob
libraries/database.php

should work.

David