Using mercurial for configuration files version control

Vadym Chepkov vchepkov at gmail.com
Thu Nov 25 07:54:12 CST 2010


Hi,

I am trying to use mercurial for tracking / populating configuration files and I am facing some obstacles I need help to overcome.
The technique works quite well with a standalone host. I usually do this:

cd /etc
hg init 
cat > .hgignore <<EOF
syntax: glob
*
EOF
hg add .hgignore
hg commit -m "Starting with empty set"

Then I add all files I modify to the repository and track changes that were made.

Now I want to use this repository to populate configuration among members of a cluster, because all changes that are made almost always absolutely the same on all nodes.

First challenge - I am not able to clone remote repository into an existing /etc directory on a second node - there is no such thing as "force", at least I wasn't able to find it.
So, instead, I did hg init on the second node and did hg pull ssh://master//etc/ . This concerns me a bit, because the repositories don't have a common "parent", don't know how essential this is.
Anyway, all works well until I added /etc/rc.conf into repository. This is one of those seldom cases where some lines in the file are different on every node.
for example, on master node

hostname="master"
ifconfig_bce0="inet 192.168.17.254 netmask 255.255.255.0"

on slave:
hostname="slave"
ifconfig_bce0="inet 192.168.17.253 netmask 255.255.255.0"

After I pulled form master's mercurial, as expected, overwrote local rc.conf, so I modified those few lines in it and committed these changes locally, without any future intents to push any local changes back to master.

And now I have a second challenge. Now every time I pull from the master it creates a new head I have to merge and commit, even changes that has nothing to do with rc.conf, but even then, if I just add one single line to the end of master's rc.conf,  I would expect mercurial to be able to duplicate this simple delta without doing any manual merges.

I realize not many use mercurial this way, so I had to describe the task in details, but I don't think I am trying to do something unreasonable and would appreciate your advice to how to do it properly.

Thank you,
Vadym Chepkov



More information about the Mercurial mailing list