使用 Glob 语法忽略 Mercurial 中的文件
我正在使用 Mercurial,并且有以下结构:
files
test
demo.jpg
video.flv
video.doc
sport
demo2.jpg
picture.jpg
text.txt
demo3.jpg
demofile3.doc
我想制作一个全局过滤器,仅忽略所有目录中作为“files”目录子级的所有“jpg”文件,
我尝试使用 files/*.jpg 但它没有不工作。
任何建议将不胜感激。
I'm using Mercurial and I have a following structure:
files
test
demo.jpg
video.flv
video.doc
sport
demo2.jpg
picture.jpg
text.txt
demo3.jpg
demofile3.doc
I want to make a glob filter that only ignore all "jpg" files in all directory that are children of "files" directory
I tried with files/*.jpg but it doesn't work.
Any advice would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您愿意忽略“名为
files
的任何目录中的所有 JPG 文件”,请使用See
hg help paths
,它解释了**
是跨越目录分隔符的全局运算符。这意味着该文件与
files/**.jpg
匹配。但请注意,glob 模式未有根。这意味着指定的文件
也将被忽略,因为它与删除
test/
前缀后的模式匹配。如果您担心这一点,则需要使用正则表达式。在该语法中,模式读取
我通常不会担心模式的根 - 我更喜欢 glob 模式的简单性。但很高兴知道如果确实需要的话,您可以根忽略模式。
If you are happy to ignore "all JPG files inside any directory named
files
", then useSee
hg help patterns
which explains that**
is a glob operator that spans directory separators. This means that the fileis matched by
files/**.jpg
.However, note that glob patterns are not rooted. This means that a file named
will also be ignored since it matches the pattern after you remove the
test/
prefix.You need to use a regular expression if you are concerned with this. In that syntax, the pattern reads
I would normally not worry about rooting the pattern -- I prefer the simplicity of the glob patterns. But it's nice to know that you can root a ignore pattern if you really have to.
它必须是 glob 语法吗?如果您使用正则表达式语法,则
files/.*\.jpg
应该可以工作。Does it have to be glob syntax? If you use regex syntax,
files/.*\.jpg
should work.正则表达式解决方案
这对我有用..
您自己的解决方案看起来更像是一个球体。技巧是使用 ** 语法来允许子目录。看到这个...
全局解决方案
适合我
这个 glob也
就我个人而言,我总是使用 glob syntx 来解决此类问题。一旦您了解了 ** 语法,就比正则表达式更容易遵循该模式试图执行的操作。
Regexp solution
This works for me ..
Your own solution looks more like a glob. The trick with that is to use the ** syntax to allow for sub directories. See this ...
Glob solution
This glob works for me too
Comments
Personally I'd always go with the glob syntx for this kind of problem. Once you know about the ** syntax, it's easier than a regexp to follow what the pattern is trying to do.