Posted on | December 10, 2010 | 2 Comments
Do you have a policy where patches that make above nn number of insertions or deletions require review before being pushed? We do, but the policy is quite loose. Actually, it is sufficiently loose to manage the whole process with simple commit hooks.
I was digging through Mercurial today to see if it had a feature to tell me how many lines I added or removed, but I didn’t see anything. So, I’m using this (somewhat inaccurate) hack to determine if a hook has to send e-mail:
hg diff -r tip | grep ^+ | sed -e '/^+++/d' | wc -lNot 100% accurate, but it does let commit hooks do trivial things for you when you commit a substantial patch. It’s basically just counting the number of insertions and removals from a diff against the previous tip.
hg diff -r tip | grep ^- | sed -e '/^---/d' | wc -l
May come in handy for someone, so I decided to post it. My last commit was 12,550 lines inserted .. and it wasn’t even a merge Yeowzers.