.hgignore syntax for ignoring only files, not directories?

后端 未结 2 1442
自闭症患者
自闭症患者 2021-02-05 22:41

I have a problem which I can\'t seem to understand. I\'m using TortoiseHg (version 0.7.5) on Windows but on Linux I have the same problem. Here it is:

My .hgignore

2条回答
  •  粉色の甜心
    2021-02-05 22:49

    I relayed this question in #mercurial on irc.freenode.net and the response was that you cannot distinguish between files and directories — the directory is matched without the slash that you're searching for in your regexp.

    However, if you can assume that your directories will never contain a full-stop ., but your files will, then something like this seems to work:

    ^[^/]*\..*$
    

    I tested it in a repository like this:

    % hg status -ui
    ? a.txt
    ? bbb
    ? foo/x.txt
    ? foo/yyy
    

    Adding the .hgignore file gives:

    % hg status -ui
    ? bbb
    ? foo/x.txt
    ? foo/yyy
    I .hgignore
    I a.txt
    

    which indicates that the a.txt file is correctly ignored in your root directory, but x.txt in the foo subdirectory is not. You can also see that a file named just bbb in the root directory is not ignored. But maybe you can add such files yourself to the .hgignore file.

    If you happen to have a directory like bar.baz in your root directory, then this directory and all files within will be ignored. I hope this helps a bit.

提交回复
热议问题