Site building and maintenance

Blog. Development. Mercurial: merge named branches


A long time ago the repository for Open Real Estate CMS was divided into three branches:

  • default - the main branch for the development;
  • demo - the version for online demo. In some places of the code there are stubs to load files to the server, ban to change passwords (it will be rather unpleasant if someone changes the password on the server and other users won’t be able to login and view the product);
  • release - the version to be released. It differs from the main branch because some of the modules (which are paid).

The robots that update the demo site, set version numbers in the releases, etc are configured in the same way. Those are the robots that made us to divide all the stuff into versions. Before that we made attempts to update all manually (create release archive, load to the demo site through FTP). But this took a lot of developer’s time - we had to change the code thrice, that’s why we decided to decrease the volume of work and made it semi-automatical.

Actually, this short note explains all main issues of using repository with named branches, for example, how to compile a correct demo, applying to demo branch the changes from the default branch.

So, we need to switch to one of the branches, for example, demo. Run:

hg update demo

Hooray! We are in demo branch. Now we have to  refresh it. The most likely, the main branch ‘moved’ much further, and there are lots of changes there. Our current demo branch is an ‘oldie’ and doesn’t include, for instance, new bug fixes. Run the command:

hg merge default

In this case all the changes (if any) in default branch will apply to the current branch. If everything went conflict-free - perfect. But what if there were some conflicts? In the previous article I started to tell about the basics of using merging tools. Well, we run the same operation - solve the conflicts (the resulting mergence code should be in the file LOCAL).

After the mergence we don’t forget to: hg commit -m "Update of demo branch"

After that we implement the changes in the branch (if any) and commit, and then we send all our changes to the server: hg push

The only moment that might shade following this instruction - it’s an error while merging:

abort: merging with a working directory ancestor has no effect

It’s not a hude deal, it’s only indicates that our demo branch contains all the latest changes.

Thanks for the attention!