mercurialignorehgignore

hg ignore all dlls under a folder


I'm having trouble getting this to work

enter image description here

I want to exclude all .dll files under the folder VirtualDlls.

I've been trying with regex and with globals but I either am getting all files excluded or none.

Global

ScriptCode.ConvertedToC#/VirtualDlls/**.dll

gets none of the files

Regex:

^ScriptCode.ConvertedToC#/VirtualDlls/.+/.+.dll$

Gets all of the files including ones ending in .cs


Solution

  • The trick is to keep it simple and understand that matches are not rooted, as explained in the hgignore documentation.

    If you want to exclude any file ending in .dll, no matter where they are, then this works:

    syntax: glob
    *.dll
    

    If you want to exclude only below the VirtualDlls directory (non-recursive):

    syntax: glob
    VirtualDlls/*.dll
    

    If you want to exclude only below the VirtualDlls directory, in a recursive way, then you have two options.

    The long one: one rule per directory level:

    syntax: glob
    VirtualDlls/*.dll
    VirtualDlls/*/*.dll
    

    The short one: use **:

    syntax: glob
    VirtualDlls/**.dll
    

    In your example you use ** too, but I think it doesn't work because it contains also the first directory, ScriptCode.ConvertedToC#.

    I tested all the examples and they all work (tested on Mac, but I don't see why they shouldn't work also on Windows).