Abe*_*bel 4 mercurial tortoisehg file-search
每次我需要标准搜索以外的任何内容时,都会发现自己在尝试几种方法,搜索Google,最后都失败了。显然,Hg搜索语法非常广泛,我想使用它的强大功能,但是我似乎找不到很好的参考。
例如,我经常想在存储库中找到与部分路径匹配有关的所有更改。我知道以下作品:
file('path:full/path/file.txt')
Run Code Online (Sandbox Code Playgroud)
但是我想通过部分匹配来搜索文件,但以下两种方法均无效:
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
Run Code Online (Sandbox Code Playgroud)
从TortoiseHg的弹出窗口中,我看到有大量的选项,但是没有有关如何使用它们的提示(帮助链接显示了更多点,但没有显示模式的外观file(pattern)):

最后,我通常会使用其他搜索方式找到我想要的东西,但是能够使用这种表达能力真是太好了,而且很遗憾的是,经过这么多年,我一直没有找到如何利用这一点。
我非常建议您使用hg帮助系统。在我看来,最有用的页面是:
hg help revsets
hg help filesets
hg help patterns
Run Code Online (Sandbox Code Playgroud)
在有关模式的页面中,您可以找到关于“路径:”的信息:
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.
Run Code Online (Sandbox Code Playgroud)
换句话说:使用'path:'不适用于此目的。在下面略微提到“ glob:”:
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".
Run Code Online (Sandbox Code Playgroud)
换句话说,应该可以使用pattern 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.
Run Code Online (Sandbox Code Playgroud)