Automagically merging ChangeLog files with mercurial or git
When a project keeps a GNU style ChangeLog file to keep track of who changed what where then those files can be automagically merged if you use mercurial or git.
gnulib contains a module git-merge-changelog which, despite the name, works perfectly with several version control systems.
To install it:
git clone git://git.savannah.gnu.org/gnulib.git cd gnulib ./gnulib-tool --create-testdir --dir=/tmp/testdir123 git-merge-changelog cd /tmp/testdir123 ./configure make make install
Mercurial
For Mercurial add the following lines to your ~/.hgrc:
[merge-patterns] ChangeLog = git-merge-changelog [merge-tools] git-merge-changelog.executable = /usr/local/bin/git-merge-changelog git-merge-changelog.args = $base $local $other
That installs the git-merge-changelog driver globally for all hg repos.
git
For git add the following lines to your ~/.gitconfig
[merge "merge-changelog"] name = GNU-style ChangeLog merge driver driver = /usr/local/bin/git-merge-changelog %O %A %B [core] attributesfile = ~/.gitattributes
And add the following line to ~/.gitattributes
ChangeLog merge=merge-changelog
Note: The global core.attributesfile exists only since git 1.7.4, before that you would have to configure this for each git repo separately, by doing:
cd ~/src/[repo-name] echo "ChangeLog merge=merge-changelog" >> .git/info/attributes
And never worry again about having to manually merge ChangeLog files.
There’s actually no point in having ChangeLog file anymore. Since the invention of VCS that file is useless.
Maybe, if commit message do contain the same information as the ChangeLog entries. Which isn’t the case in some projects. And sometimes sources are distributed separate from the VCS, then having a ChangeLog file is handy. There are also other tools to generate ChangeLog files from various CVS commit messages. But some projects do have ChangeLog files. And in that case having automatic ChangeLog entry merging is pretty convenient.