Search code examples
c++mercurialanalysischangeset

Mercurial changeset c++ analysis


Is there some way to analyze C++ mercurial changeset to figure out for example the function or class modified?

I would like to get statistics of the amount of revisions of some part of the code: methods, classes, files, folders, etc.


Solution

  • Not sure how good this is when working with C++, but Mercurial optionally uses git-format diffs. Both git diff and hg diff have an option to view the function in which a change was made... in Mercurial you can use hg diff -p:

    > hg diff
    diff --git a/sandbox/sandbox.cpp b/sandbox/sandbox.cpp
    --- a/sandbox/sandbox.cpp
    +++ b/sandbox/sandbox.cpp
    @@ -86,6 +103,8 @@
    ... diff output removed for conciseness
    
    > hg diff -p
    diff --git a/sandbox/sandbox.cpp b/sandbox/sandbox.cpp
    --- a/sandbox/sandbox.cpp
    +++ b/sandbox/sandbox.cpp
    @@ -86,6 +103,8 @@ int _tmain(int argc, _TCHAR* argv[])
    ... diff output removed for conciseness
    

    Notice that with the -p option, each chunk of the diff output includes the containing functions (_tmain in this case). Note that new functions don't appear to include that information.

    I'm not sure how you would use this, mind. Perhaps grep the output for lines containing @@.*\(.*\) to get a list of functions?