Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial repository statistics, for finding candidates for refactoring?

Tags:

mercurial

In a busy repository, I can foresee some files with too much central logic in one place being edited constantly.

Is there any way to find such files by asking Mercurial, either through bundled extensions, 3rd party extensions, or any external tools?

Basically I'd like some statistics that shows files that are edited the most over time, so that I can use this to find candidates for splitting, like refactoring the code into multiple files, to avoid having constant merge pain for single files.

I'm aware of the churn extension, but it seems to only focus on how much each author does to the repository, not what the authors do it to.

like image 442
Lasse V. Karlsen Avatar asked Nov 06 '10 19:11

Lasse V. Karlsen


1 Answers

I don't think any of the churn, activity, or chart extensions does exactly that, though they're all a simple tweak away from it I think (they group by user not by file).

You could use a loop like:

for therev in $(seq 1 $(hg id -n -r tip)) ; do
  hg diff --change $therev --stats
done

And then total by file.

like image 100
Ry4an Brase Avatar answered Sep 21 '22 20:09

Ry4an Brase