Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mercurial Glob语法用于匹配文件名中的字符_Mercurial - Fatal编程技术网

Mercurial Glob语法用于匹配文件名中的字符

Mercurial Glob语法用于匹配文件名中的字符,mercurial,Mercurial,我花了一段时间试图找出忽略与特定模式匹配的文件的语法,即:Com.Example/Com.Example.DomainModel23012013101705.somefileextension。变量似乎是嵌入文件名的日期(23012013101705) 我尝试过[0-9]。somefileextension和其他模式都没有用 谢谢,, Stephen使用正则表达式而不是glob。Mercurial支持任何一种。在.hgignore中,这将是: syntax: regexp [0-9]\.some

我花了一段时间试图找出忽略与特定模式匹配的文件的语法,即:Com.Example/Com.Example.DomainModel23012013101705.somefileextension。变量似乎是嵌入文件名的日期(23012013101705)

我尝试过[0-9]。somefileextension和其他模式都没有用

谢谢,,
Stephen使用正则表达式而不是glob。Mercurial支持任何一种。在
.hgignore
中,这将是:

syntax: regexp
[0-9]\.somefileextension
该正则表达式与您尝试的glob匹配,但您当然可以将其缩小为:

syntax: regexp
^Com\.Example/Com\.Example\.DomainModel\d+\.somefileextension$

遗憾的是,Ry4an犯了错误。Grep()不适用于文件名

我的“试验场”

测试

>hg locate "set:grep(html5)\.php"
hg: parse error at 11: invalid token

注意:找到了文件,其中包含文本“html5”,但不是文件html5.js


设置了
前缀和regexp的所有测试均失败


使用set的不同glob模式:

>hg locate "set:s**.php"
search.php
sidebar.php
single.php

>hg locate "set:s**.*"
screenshot.png
search.php
sidebar.php
single.php
style.css

>hg locate "set:s**e.*"
single.php
style.css

文件集中的Regexp模式

>hg locate "re:s[a-z]+.php"
search.php
sidebar.php
single.php

>hg locate "re:s[a-z]+."
screenshot.png
search.php
sidebar.php
single.php
style.css
继续

hg忘记“re:Com\.Example\.DomainModel[0-9]+\.somefileextension$”

hg“set:Com.Example.DomainModel**.somefileextension”


同样设置为hgignore

太宽的regexp,并且,对不起,grep()验证内容,而不是文件名(AFAIK)@lazybagger我创建regexp是为了匹配askers glob——我同意我自己会使用更窄的regexp。你说的对
grep()
how embarassing.只是将我的hgignore文件更改为使用更严格的版本。。在。。再次感谢您。幸运的是,我只关心hgignore,没有测试文件代码,另一方面,正则表达式在我的初步测试中起了作用。谢谢你的跟进。
>hg locate "set:s[a-z]+\.php"
abort: \.php not under root

>hg locate "set:s[a-z]+.php"

>hg locate "set:s[a-z]+"
hg: parse error at 7: not a prefix: end

>hg locate "set:s\w+"
hg: parse error at 4: not a prefix: end
>hg locate "set:s**.php"
search.php
sidebar.php
single.php

>hg locate "set:s**.*"
screenshot.png
search.php
sidebar.php
single.php
style.css

>hg locate "set:s**e.*"
single.php
style.css
>hg locate "re:s[a-z]+.php"
search.php
sidebar.php
single.php

>hg locate "re:s[a-z]+."
screenshot.png
search.php
sidebar.php
single.php
style.css