hg grep --exclude pattern
Asked Answered
C

2

7

How do you specify the --exclude/-X parameter when using hg grep?

I've tried every kind of bare and pattern syntax I've ever come across (including a few regex dialects I know), but I can't even get it to work with the most simple example.

I'm mostly interested in filtering out some binary files and minified JavaScript files (*.min.js) from the search.

I'm on Windows, if that's pertinent.

Corny answered 5/6, 2012 at 18:54 Comment(0)
U
9

See hg help patterns. By default, the pattern is treated as a shell glob.

If you want to use a regular expression, you can try something like this:

hg grep -X "re:.*\.min\.js$" <search term>
Unshapen answered 5/6, 2012 at 19:12 Comment(3)
Perfect answer; thank you! Google Search failed me in producing a link to that page.Corny
Forget google search hg help would have gotten you there very quickly.Bernt
@Ry4an: I know that now yes. I did read hg help furiously, but didn't notice the hg help patterns section. A note in the hg help grep section ("see: hg help patterns") would've been beneficial.Corny
H
2

hg help patterns explains that Globs are rooted at the current directory; a glob such as "*.c" will only match files in the current directory ending with ".c". So to match any file with an extension .min.js using a glob you'll need a leading wildcard like --exclude '**/*.min.js'

Harmonicon answered 23/10, 2021 at 22:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.