문제

Mercurial can be configured to ignore files whose filename have a certain extension. For example, *.txt files can be ignored by adding this to ~/.hgignore:

syntax: glob
*.txt

How can I setup my .hgignore file to ignore files whose filenames have no extensions? For example, files named foobar and abracadabra should be ignored, but foobar.cpp and abracadabra.c should be tracked.

도움이 되었습니까?

해결책

Use regexp syntax instead since it's not possible with glob:

syntax: regexp
^[^.]+$

PS: you can add it right after your syntax: glob section

다른 팁

If you have a small list of files without extension that you want to ignore, then you can just list them as glob patterns:

syntax: glob
foobar
abracadabra

If you want to ignore all files without an extension, then things become more difficult. If you use the regexp provided by zerkms,

syntax: regexp
^[^.]+$

then you will also ignore directories without an "extension", that is directories without . in their names such as src, and so on.

Because Mercurial matches files and directories top-down while traversing your working copy, and because it doesn't distinguish between files and directories when matching against the patterns in the .hgignore file, you cannot include a directory while ignoring files with the same name.

(You can simulate the opposite: by ignoring foobar/ in regexp syntax you end up ignoring all files inside foobar/ while not ignoring a file named foobar in another directory.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top