Search code examples
c++mercurialdiff

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


I would like to get the C++ function names in a file. I tried do this with the command diff because I only need get the name of the function which is modified but I could not get it. I know that with python files it is possible using git with the option 'git diff file.py'. Is it possible do it with c++ files in Mercurial?


Solution

  • I think you are looking for the config option diff.showfunc. The doc (hg help config) says:

    "showfunc"
        Show which function each change is in.
    

    It's working fine for Python functions and I think the heuristic should work similarly for C++ files. Maybe it will need functions body to be indented to correctly detect C++ functions.