Is it possible to use rooted glob patterns in .hgignore?

最后都变了- 提交于 2019-12-05 14:28:00

问题


I prefer to use glob syntax in my .hgignore files, but now I need to create a rooted pattern. I want to ignore my /static directory, but not /assets/static. The line

static/

ignores both. Is there a way to do rooted glob patterns? If not, I can switch to regex, but glob just seems so much more natural for matching pathnames.


回答1:


You cannot root your glob patterns — this is documented in the manpage. You can, however, switch back and forth between the glob and regexp syntax:

syntax: glob
*.pyc

syntax: regexp
^static/

syntax: glob
*~



回答2:


According to hgignore (5), it's not possible with globs:

Neither glob nor regexp patterns are rooted. A glob-syntax pattern of the form *.c will match a file ending in .c in any directory, and a regexp pattern of the form .c$ will do the same. To root a regexp pattern, start it with ^.



来源:https://stackoverflow.com/questions/10673783/is-it-possible-to-use-rooted-glob-patterns-in-hgignore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!