Using mercurial for configuration files version control

Tom Widmer tom.widmer at googlemail.com
Thu Nov 25 15:52:36 UTC 2010


On 25/11/2010 13:54, Vadym Chepkov wrote:
> 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.

They do have a common parent - the revision 0 is identical for all repos 
and is acting as the common parent in this case.

  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.

That sounds fine.

> 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.

With DVCSes, merging is expected and normal whenever you pull and you 
have made a local commit. The merge should produce no conflicts, so you 
can just commit straight away. Alternatively, you could enable the 
'fetch' extension and do 'hg fetch', which performs the merge and then 
an automated commit if there were no merge conflicts (as will usually be 
the case in your workflow).

Tom




More information about the Mercurial mailing list