I'm using Mercurial and I have a following structure:
files
test
demo.jpg
video.flv
video.doc
sport
demo2.jpg
picture.jpg
text.txt
demo3.jpg
demofile3.doc
I want to make a glob filter that only ignore all "jpg" files in all directory that are children of "files" directory
I tried with files/*.jpg but it doesn't work.
Any advice would be appreciated.
If you are happy to ignore "all JPG files inside any directory named files
", then use
syntax: glob
files/**.jpg
See hg help patterns
which explains that **
is a glob operator that spans directory separators. This means that the file
files/test/demo.jpg
is matched by files/**.jpg
.
However, note that glob patterns are not rooted. This means that a file named
test/files/demo.jpg
will also be ignored since it matches the pattern after you remove the test/
prefix.
You need to use a regular expression if you are concerned with this. In that syntax, the pattern reads
syntax: regex
^files/.*\.jpg
I would normally not worry about rooting the pattern -- I prefer the simplicity of the glob patterns. But it's nice to know that you can root a ignore pattern if you really have to.
This works for me ..
syntax: regexp
files/.*/.*jpg
Your own solution looks more like a glob. The trick with that is to use the ** syntax to allow for sub directories. See this ...
This glob works for me too
**/files/**/*.jpg
Personally I'd always go with the glob syntx for this kind of problem. Once you know about the ** syntax, it's easier than a regexp to follow what the pattern is trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With