hook to limit size of changeset(s)?
Hans Fangohr
h.fangohr at soton.ac.uk
Thu May 8 06:01:08 CDT 2008
Dear all,
I have discovered Mercurial only recently, and am delighted! Thank
you to everybody who help with this, and thank you also for
documenting hg well.
It appeared to be a good idea to have a check that no very large files
are commited (such as binaries) etc. So I thought I could write a hook
(using pretxncommit or pretxnchangegroup) that that will look at the
size of the patch of the latest attempted commit (i.e. something like
"hg log -p $HG_NODE | wc --bytes" and combines this with an if
statement to see whether it exceeds a given upper size limit. This
works (for changes in non-binary files) and for the examples I have
tested.
Here are my questions:
- is this overall a good idea? (My motivation is to exclude bogus
commits with large files from people who are either unexperienced or careless [which
may well include myself].) Will this always work? Are there issues
with merging branches (such that a collection of changesets appears
to be a large change?)
- the chosen approach (using 'log -p' will not give enough output
data for binary files as it just states that a binary file has
changed). I could use 'hg diff --text -r $HG_NODE -r XXX' but don't
know which other revision XXX I should compare against.
I have been digging around a bit and couldn't find this covered
anywhere. Maybe it is just a bad idea?
Any comments welcome.
Thanks,
Hans
More information about the Mercurial
mailing list