如何在 hg diffs 中获取 C++ 函数名称?

How to get C++ function names in hg diffs?

我想获取文件中的 C++ 函数名称。我尝试使用命令 diff 执行此操作,因为我只需要获取修改后的函数的名称,但我无法获取它。 我知道对于 python 文件,可以使用带有选项 'git diff file.py' 的 git。 是否可以在 Mercurial 中使用 C++ 文件来实现?

我认为您正在寻找配置选项 diff.showfunc。文档 (hg help config) 说:

"showfunc"
    Show which function each change is in.

它对 Python 函数工作正常,我认为启发式应该对 C++ 文件类似地工作。也许需要缩进函数体才能正确检测 C++ 函数。