在 Mercurial 或 TortoiseHg 中搜索部分文件或路径的更改历史
Searching for the change history of partial file or path in Mercurial or TortoiseHg
每次我需要标准搜索以外的任何东西时,我发现自己尝试了几种方法,搜索 Google,但最终都失败了。显然,Hg 搜索语法非常广泛,我想利用它的强大功能,但我似乎无法找到一个好的参考。
例如,我经常想在存储库中找到与部分路径匹配相关的所有更改。我知道以下工作:
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 的弹出窗口中我看到有无数的选项,但没有关于如何使用它们的提示(帮助 link 显示了更多一点,但没有说明 pattern 应该看起来像 file(pattern)
):
最后我通常会通过其他方式找到我想要的东西,但如果能够使用这种表达能力就好了,很遗憾,这么多年了,我已经从未发现如何利用它。
我非常建议为此使用 hg 帮助系统。最有用的页面(在我看来):
hg help revsets
hg help filesets
hg help patterns
在关于模式的页面中,您可以找到关于 'path:':
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.
换句话说:使用 '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".
换句话说,应该可以使用模式file('glob:**jquery*')
。
事实上,上面的模式在没有 glob 前缀的情况下也可以工作,所以:file('**jquery*')
。请参阅有关 revsets 的部分页面:
"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.
每次我需要标准搜索以外的任何东西时,我发现自己尝试了几种方法,搜索 Google,但最终都失败了。显然,Hg 搜索语法非常广泛,我想利用它的强大功能,但我似乎无法找到一个好的参考。
例如,我经常想在存储库中找到与部分路径匹配相关的所有更改。我知道以下工作:
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 的弹出窗口中我看到有无数的选项,但没有关于如何使用它们的提示(帮助 link 显示了更多一点,但没有说明 pattern 应该看起来像 file(pattern)
):
最后我通常会通过其他方式找到我想要的东西,但如果能够使用这种表达能力就好了,很遗憾,这么多年了,我已经从未发现如何利用它。
我非常建议为此使用 hg 帮助系统。最有用的页面(在我看来):
hg help revsets
hg help filesets
hg help patterns
在关于模式的页面中,您可以找到关于 'path:':
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.
换句话说:使用 '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".
换句话说,应该可以使用模式file('glob:**jquery*')
。
事实上,上面的模式在没有 glob 前缀的情况下也可以工作,所以:file('**jquery*')
。请参阅有关 revsets 的部分页面:
"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.