Mercurial Precommit Isn't Entirely "Pre"
I've been battling with Mercurial's precommit hook for a while now trying to get it to do as I wanted, only to find it's not as "pre" as it or the documentation would lead you to believe.I've been using Mercurial now for some time for all my version control needs, including all my web development. One of the things I like to do is ensure the version number in the application/web page is correct and accurate (as I use hg code in production). So I whipped up a quick shell script that took the current repo revision (hg id -n | tr -d '+'), added 1 and then replaced all instances of my version strings with the repo tag (hg tags -q | grep -v tip | head -1) and revision in the form "{tag}r{rev}", eg 1.0r34.The shell script works a treat, but I was finding after running a commit, hg stat still reported several files had been modified, which they had as the precommit script modified them. These were always files I hadn't modified prior to the commit, but were modified by the precommit script. Continue reading ►