mercurialcode-size

Viewing repository size over time


Is there a way to get the size of a repository for a given revision? I would like to create a graph showing how the size changes over time.


Solution

  • Inspired by planetmaker's answer I wrote this command:

    hg log -r0:tip --stat --template 'date: {date|shortdate}\n' \
        | awk \
            '/^date:/ { date = $2 }
            /^ *[0-9]+ files changed/ { sum += $4 - $6; print date, sum }' \
        | awk \
            '$1 != prevDate { if (prevLine != "") { print prevLine } }
            { prevLine = $0; prevDate = $1 }
            END { print prevLine }'
    

    The second awk command filters out multiple commits with the same date, so that only the last commit on a given date is shown.

    Example output:

    2014-09-22 304
    2014-10-25 308
    2014-12-25 320
    2014-12-27 253
    2015-03-17 252
    2015-04-28 230
    2015-05-22 241
    2015-08-12 301
    2015-07-13 302
    2015-08-12 306
    

    Update 2015-08-19: Account for commits with no file changes (happens with merges sometimes).