Mercurial .hgignore frustration
Domanda
I have a RE checker that says this should work. What am I doing wrong?!?
Example of what I am trying to ignore:
apps/cms/templates/cms/test_bup_DEPRECATED/widgets/page_link.html
And my .hgignore file:
syntax: regexp
^static
.*_DEPRECATED.*
I have tried all sorts of things and no success :(
Another failed attempt:
syntax: glob
_DEPRECATED/*
UPDATE: I edited the .hgignore file to this:
syntax: glob
**_DEPRECATED/**
But hg st still doing this:
$ hg st | grep DEPR
A apps/cms/templates/cms/test_DEPRECATED/base.html
Same result for this:
syntax: glob
_DEPRECATED
Soluzione
First, .hgignore
won't ignore files already tracked by Mercurial. Your example indicates the file is already tracked:
$ hg st | grep DEPR
A apps/cms/templates/cms/test_DEPRECATED/base.html
The file has already been added, but not committed. Use hg forget
to forget about the file, and then the ignore pattern will take effect.
.hgignore
patterns match any part of the path, so this is all you need:
syntax: regexp
_DEPRECATED/
Note you may want the trailing slash for a directory or it will match files ending in _DEPRECATED
as well, otherwise drop it.
To work out ignore patterns, the ignore GUI in TortoiseHg (thg ignore
) is very helpful. It displays all files not tracked and not ignored, and patterns can be entered until the right files are ignored.
Altri suggerimenti
The right answer:
syntax: glob
**_DEPRECATED/**
Example:
$ cat .hgignore
syntax: glob
**_DEPRECATED/**
$ find . | fgrep -v /.hg/
.
./.hgignore
./apps
./apps/cms
./apps/cms/templates
./apps/cms/templates/cms
./apps/cms/templates/cms/file
./apps/cms/templates/cms/test_bup_DEPRECATED
./apps/cms/templates/cms/test_bup_DEPRECATED/widgets
./apps/cms/templates/cms/test_bup_DEPRECATED/widgets/page_link.html
$ hg st
? apps/cms/templates/cms/file
I think it is the * characters you have in your regexp. I think because * means 0 or more, that regexp would match at position 0 of your string, ignoring every file, which hgignore interprets as a mistake, nulling out your expression.
I would use just "_DEPRECATED" (without the quotes), as this will match at character 31 of your string. I picked this subset as it looks like you are trying to ignore any file with the string _DEPRECATED in it. If this isn't the match you are going for, let me know and I'll try to come up with a different regexp you can use.
Also, are you trying to ignore any file starting with the characters "static", because that is what the other line looks like it is doing.
Also, there is a glob syntax you can use which is more straightforward than regular expressions. You can use thus syntax to easily ignore whole directories. I don't know how you have laid out your project, but if ignoring a whole directory accomplishes your goal, this is an easy way to do it.
More documentation is here: http://www.selenic.com/mercurial/hgignore.5.html