Tuesday, September 6, 2022

[SOLVED] hg grep --exclude pattern

Issue

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.


Solution

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>


Answered By - Tim Henigan
Answer Checked By - Dawn Plyler (WPSolving Volunteer)