.hgignore语法仅忽略文件,而不忽略目录? [英] .hgignore syntax for ignoring only files, not directories?

查看:192
本文介绍了.hgignore语法仅忽略文件,而不忽略目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个似乎无法理解的问题.我在Windows上使用TortoiseHg(0.7.5版),但是在Linux上,我有同样的问题.在这里:

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:

我的.hgignore文件:

syntax: regexp
^[^\\/]+$

我要实现的目标是将hg存储库根目录中的文件添加到忽略列表中.

What I'm trying to achieve is to add to the ignore list the files which are in the root of the hg repository.

例如,如果我有这样的话:

For example if I have like this:

.hg
+mydir1
+mydir2
-myfile1
-myfile2
-anotherfile1
-anotherfile2 
.hgignore

我希望忽略myfile1(2)和anotherfile1(2)(名称仅出于本示例的目的-它们没有简单的规则可以轻松地放入hgignore文件中)

I want myfile1(2) and anotherfile1(2) to be ignored (names are only for the purpose of this example - they don't have a simple rule that can be put in the hgignore file easily)

因为我可以肯定正则表达式很好(我什至对其进行了测试),所以我缺少某些东西吗?想法?

Is there something I'm missing because I'm pretty sure that regexp is good (I even tested it)? Ideas?

有没有更简单的方法来实现这一目标? [将添加到Mercurial存储库根目录中的忽略列表文件中

Is there a simpler way to achieve this? [to add to the ignore list files that are in the root of the mercurial repository]

推荐答案

我在irc.freenode.net上的#mercurial中转发了这个问题,响应是您无法区分文件和目录-目录匹配时没有您在正则表达式中搜索的斜线.

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

添加.hgignore文件将提供:


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

表示您的根目录中的a.txt文件已被正确忽略,但foo子目录中的x.txt却未被正确地忽略.您还可以看到,根目录中仅名为bbb的文件被 not 忽略.但是也许您可以自己将这些文件添加到.hgignore文件中.

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.

如果您的根目录中恰好有一个类似于bar.baz的目录,则该目录和其中的所有文件都将被忽略.我希望这会有所帮助.

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.

这篇关于.hgignore语法仅忽略文件,而不忽略目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆