2015-06-09 79 views
3

每当我需要标准搜索之外的任何内容时,我发现自己尝试了几件事情,搜索Google并最终导致严重失败。显然,Hg搜索语法非常广泛,我想使用它的能力,但我似乎无法找到一个很好的参考。搜索Mercurial或TortoiseHg中部分文件或路径的更改历史记录

例如,我经常想查找与部分路径匹配相关的存储库中的所有更改。我知道了以下工作:

file('path:full/path/file.txt') 

但我想搜索的部分匹配的文件,也不以下工作:

jquery     -- seems to find everything 
file(jquery*)   -- finds nothing 
file('jquery*')   -- finds nothing 
file('path:jquery.*') -- finds nothing 
file('name:jquery.*') -- finds nothing 
file('path:jquery.js') -- finds every revision, it seems 

从TortoiseHg弹出我看到有一个极大的选择,但对如何使用它们没有提示(帮助链接显示多一点点,但没有一个模式应该是什么样子的file(pattern)):

enter image description here

最后,我通常会用其他搜索方法找到我想要的东西,但能够使用这种表达力量真是太好了,而且很遗憾,经过这么多年,我从来没有发现如何利用这一点。

回答

4

我可以非常建议使用hg帮助系统。最有用的网页看看(我认为):

hg help revsets 
hg help filesets 
hg help patterns 

在关于模式的页面,你可以找到关于“路径:”:

To use a plain path name without any pattern matching, start it with 
"path:". These path names must completely match starting at the current 
repository root. 

换句话说:使用“路径: '不适合这个目的。略低于“水珠:”中提到:

To use an extended glob, start a name with "glob:". Globs are rooted at 
the current directory; a glob such as "*.c" will only match files in the 
current directory ending with ".c". 

The supported glob syntax extensions are "**" to match any string across 
path separators and "{a,b}" to mean "a or b". 

换句话说,应该有可能使用图案file('glob:**jquery*')。 实际上,上面的模式也可以不用glob前缀,所以:file('**jquery*')。请参阅页面的一部分关于修订:

"file(pattern)" 
    Changesets affecting files matched by pattern. 

    For a faster but less accurate result, consider using "filelog()" 
    instead. 

    This predicate uses "glob:" as the default kind of pattern. 
+0

太棒了!的确,'file('** jquery *')'做了诀窍。不能相信我尝试过'**'语法,但没有附加的单个通配符“*”。感谢有关这方面的帮助。 – Abel