Looking to quantify how much change happened in each changeset. Any quick way to list maybe kb diff between two revisions?
4 Answers
I had the same thought as @shambulator yesterday! So I've added ability to print delta size in bytes as a part of --diffstat
output from my somewhat long and clean patch.py utility.
wget https://raw.githubusercontent.com/techtonik/python-patch/master/patch.py
hg diff -c tip | python patch.py --diffstat --
codereview/views.py | 28 ++++++++++++++++++++++++++++
index.yaml | 10 ++++++++++
2 files changed, 38 insertions(+), 0 deletions(-), +1267 bytes
UPD: Thanks to @Gili and @mforbes there is now a ticket for Mercurial
https://bz.mercurial-scm.org/show_bug.cgi?id=4245

- 1
- 1

- 19,847
- 9
- 124
- 140
-
Thanks for the script! I filed a ticket: http://bz.selenic.com/show_bug.cgi?id=4245 – Gili May 13 '14 at 03:29
-
That may help. Thanks. – anatoly techtonik May 14 '14 at 09:24
-
The bug server is now at https://bz.mercurial-scm.org/show_bug.cgi?id=4245 – mforbes Mar 15 '17 at 21:35
-
The source has moved to GitHub: https://github.com/techtonik/python-patch/blob/master/patch.py – Kim Apr 20 '17 at 14:44
Perhaps one can use hg bundle
to check the size? (I have not checked how consistent this is in terms of the total repository size.)
function revsize() {
hg bundle -r $1 --base "p1($1)+p2($1)" /dev/stdout | wc -c
}
How it works
This computes the size (in bytes) using wc -c
after generating a bundle for the changes between revision REV = $1
(the first argument to the bash function) and its parents "p1(REV)+p2(REV)"
(there may be two if it is a merge.) By using /dev/stdout
as a file, the result is sent to standard out where it can be piped to wc -c
without creating a file on disk.

- 7,062
- 3
- 16
- 21
-
Note that by default, bundles are compressed using bzip2. For no compression, use "-t none" (see hg bundle docs linked above). – Kim Apr 20 '17 at 15:53
-
@Kim Do you know if the differences are stored compressed on disk or not? If not, ``-t none`` is probably best, but this all needs some testing (or an authoritative source.) – mforbes Apr 20 '17 at 23:29
-
According to this ancient [answer](http://stackoverflow.com/a/1270485/3387608), initial files are compressed, but diffs are uncompressed. I haven't verified this independently or found a more recent confirmation though. – Kim Apr 21 '17 at 14:47
hg log --stat
is the command you're after. See this example:
$ hg log --stat
changeset: 12431:56e146c7beef
user: flast
date: Wed Jun 08 16:12:54 2011 +1000
summary: Fix the frobulate to frob the knob correctly on tuesdays.
path/to/src/frob/interface.py | 29 ++++++++++++++++++++---------
path/to/tests/systest_frob.py | 14 ++++++++++++++
2 files changed, 34 insertions(+), 9 deletions(-)

- 41,746
- 15
- 73
- 90
I had the same thought only yesterday! I wrote a quick and dirty Python script for determining total file size change given a unified diff on stdin or as files on the command line. To do it for a changeset, you could just:
hg diff -c <cset id> | patchsize.py
Quick and dirty in the sense that it probably doesn't account for platform-specific line endings, and it doesn't parse diffs particularly cleverly. But it's close enough for my purposes.

- 5,637
- 32
- 48
-
2Yep, I use it all the time. But it only goes as far as line insertions and deletions; I was curious about the total change in file sizes introduced by a patch. – anton.burger Jun 10 '11 at 12:50