使用负前瞻珩磨.hgignore文件 [英] Honing the .hgignore file using a negative lookahead

查看:83
本文介绍了使用负前瞻珩磨.hgignore文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经查看了其他几个有关汞汞的文件,但是我无法使我的正则表达式正常工作.

I've looked at a handful of the other Hg hgignore file questions, but I haven't been able to get my regex to work.

想象一下这些文件:

Projects/search.intrasearch/newUI/override/xslt/foo.xsl
Projects/search.intrasearch/newUI/default/
Projects/search.intrasearch/oldUI/baz/

我想忽略后两行,但不要忽略前两行.因此,在Mercurial中,我想 include 文件在newUI/override目录中,它是子目录,仅此而已.在实际的系统中,目录比上面更多,因此简单地排除oldUI和default将不起作用.我需要一种包含的方法.

I want to ignore the second two lines, but not the first. So, in Mercurial, I want to include files in the newUI/override directory and it's children, but that's it. In the real system, there are a bunch more directories than above, so simply excluding oldUI and default won't work. I need a method of inclusion.

这在正则表达式工具中有效,但在Mercurial中无效:

This works in a regex tool, but not in Mercurial:

(?i)Projects/search\.intrasearch/(?!newUI/override).*

推荐答案

我终于通过结合使用两个正则表达式来解决了这个问题:

I finally figured this out by using a combination of two regex's:

(?i)Projects/search.*?/newUI/(?!override).*
(?i)Projects/search[^/]*/(?!newUI).*

这似乎已成功排除了newUI的同级项和覆盖的同级项.

This seems to successfully exclude anything that's a sibling to newUI and anything that's a sibling to override.

这篇关于使用负前瞻珩磨.hgignore文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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