October 31, 2008

Activity extension for mercurial

by orzel
Categories: Admin, Gentoo, KDE, Software
Tags: , ,
Comments: 8 Comments

example : activity of the mercurial "crew" repository

This is something i’ve really been missing for long in mercurial : a way to display the activity of a repository. No, ‘hg churn’ is not the right answer, I want an idea of when the peaks of development happened. So I have written this small extension. It is based on matplotlib, so you’ll need that to be installed. It is tested with mercurial 1.0.2 and the current development version of mercurial (so-called mercurial ‘crew’ repository). I’m a big fan of this kind of information, and I’m sure to use this extension regularly, so you can count on it being maintained.

To use is, grab a copy :

hg clone http://sources.freehackers.org/Hgactivity/

and add a line in your ~/.hgrc under [extensions] with the full path to the activity.py (example on my computer, please adapt to your actual path:)


To use it, just do from inside a repository:

hg activity

The first example shows the activity for the mercurial.crew repository, and here’s another one representing the activity of the the ‘kdebase’ module from kde (I have a local mercurial mirror):

Activity of kdebase in the last month
Activity of kdebase during the last month

Homepage of the project: http://labs.freehackers.org/wiki/hgactivity


  1. Andreas says:

    Well, I have a *public* kdebase mirror:
    Also kdelibs, kdepimlibs, kdepim.
    Ceteri censeo that mercurial is a friendlier and more approachable DCVS than git.

  2. @andreas
    Oh, great to know 🙂

  3. Andreas says:

    erm… s/DCVS/DVCS/ (freudian slip?) 😮

  4. […] I seem to be fond of activity graphs those days. I have reused part of this prevous code, but this time I parse the emerge log file to display the activity of your successful emerges. […]

  5. Jonathan says:

    This was almost exactly what I was looking for. My repository has a lot of auto generated stuff in it too though, which is useful but I don’t really care about the activity of. I made a small modification to include the directories I was interested in (based upon version 1.4).

    *** hgactivity-1.4/activity.py Thu Feb 10 13:48:48 2011
    --- hgactivity-1.4-mod/activity.py Fri Mar 25 17:45:05 2011
    *** 124,129 ****
    --- 124,130 ----
    ('', 'datemax', '', _('End date of the graph (yyyy-mm-dd)'), 'string'),
    ('', 'maxcaptions', 4, _('Maximum number of captions (when using --split).'), 'integer'),
    ('x', 'exclude', '', _('Comma-separated list of authors to ignore.'), 'string'),
    + ('i', 'include', '', _('Comma-separated list of directories to include.'), 'string'),
    ('', 'aliases', '', _('file with email aliases'), 'string'),
    ('', 'skipmerges', False, _('Do not consider merge commits')),
    ('l', 'uselines', False, _('Use the number of lines modified instead of the number of commits')),
    *** 171,176 ****
    --- 172,183 ----
    options.exclude = []

    + include = opts.get('include')
    + if include:
    + options.include = include.split(',')
    + else:
    + options.include = []
    if hasattr(repo.changelog,'count'):
    options.length = repo.changelog.count() # mercurial 1.0.2 and previous
    *** 301,307 ****
    if '' in dirs:
    dirs[dirs.index('')] = ''
    for dir in dirs:
    ! yield dir , localstat

    def convolution(datemin,datemax,data):
    date = datemin
    --- 308,315 ----
    if '' in dirs:
    dirs[dirs.index('')] = ''
    for dir in dirs:
    ! if dir in options.include:
    ! yield dir , localstat

    def convolution(datemin,datemax,data):
    date = datemin

  6. Hi,

    Well, why not, but this (old) blog entry is really not the place for patch proposal.. please use the tracker from the homepage (there’s even a tracker “patch”).

  7. Andi says:

    The repository is actually http://sources.freehackers.org/Hgactivity (watch out for the capital H) otherwise one will get a 404.

  8. Indeed. It was not yet capitalized when i wrote this post, but it has changed and now is. I’ve fixed the article, thanks for reporting.

Leave a Reply

Your email address will not be published. Required fields are marked *