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.
Viewing repository size over time
121 Views Asked by August Karlstrom AtThere are 2 best solutions below

It's a tricky question.
First: what is 'size'? Is it the size in bytes? Or is it the number of lines of code?
If the answer is 'bytes', then there is no other way than to checkout each revision, purge the working directory and check the size of the working directory.
If the answer is 'lines of code' and the repository contains text files exclusively, then you might do without checking out each revision, using hg log --stat
(see also How Can I calculate the sum of a specific column using bash? ):
LC_ALL=C hg log -r0:tip --stat | grep 'insertions' | awk '{sum+=$4 ; min+=$6; print $4,$6} END {print "sum=",sum-min}'
This is tested with hg 3.4.2, but I'm not aware of any significant changes in the output of hg log --stat
Inspired by planetmaker's answer I wrote this command:
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:
Update 2015-08-19: Account for commits with no file changes (happens with merges sometimes).