Search code examples
version-controlmercurialdvcshgignore

hg add whole directory despite being listed in the .hgignore


I have two branches in my mercurial repository with the same .hgignore file: dir/

One branch (development) should ignore this directory, while the other (release) should not ignore it. I know I can use hg add dir/somefile despite the entry in the .hgignore file. But now I would like to add the whole directore recursively.

I searched for that and tried

hg add dir    # does not add anything
hg add dir*   # does not add anything
hg add dir/   # does not add anything
hg add dir/*  # only adds the files in dir but not in sub-directories
hg add dir/** # only adds the files in dir but not in sub-directories

But that thas not work recursively. I could use add dir/* dir/*/* dir/*/*/* and so on, but that is annoying. Is there another wildcard I have to use instead or maybe another way to accomplish this?

PS: I would like to avoid to change the .hgignore.


Solution

  • In the meantime, I was able to come up with—what seems to be—a solution:

    hg add --dry-run --verbose `hg status --ignored --no-status --exclude **.DS_Store dir/`
    

    This shows a list of files that it would add. If you really want to add them, use the following command:

    hg add `hg status --ignored --no-status --exclude **.DS_Store dir/`
    

    Hope this helps someone.