Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to repeatedly merge branches in Mercurial

We're using Mercurial where I work and I want to have a setup similar to how I used SVN:

  • Trunk
  • Tags
    • Production
  • Branches

Since Mercurial supports branches natively, I know how to create a named branch, but I can't find any documentation on how to repeatedly merge 'Trunk' with 'Production'.

Quite simply, I want to have a development branch for normal work and a production branch that I routinely pull changes from the development branch into. How do I do this with Mercurial?

like image 832
Ryan Doherty Avatar asked Sep 08 '08 17:09

Ryan Doherty


People also ask

How do I merge branches in Mercurial?

To merge two branches, you pull their heads into the same repository, update to one of them and merge the other, and then commit the result once you're happy with the merge. The resulting changeset has two parents.

How do you combine two Mercurial heads?

To start a merge between the two heads, we use the hg merge command. We resolve the contents of hello. c This updates the working directory so that it contains changes from both heads, which is reflected in both the output of hg parents and the contents of hello.

How do I merge two branches in a new branch?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.

How do I close a branch on Tortoisehg?

when you are on your NewFeature branch (no need to have anything to commit - or you do it with your final merge) click "Branch: NewFeature" (it's at the top in bold) select "Close current branch".


1 Answers

As the previous poster mentioned, the transplant extension can be used for cherry-picking individual changes from one branch to another. If, however, you always want to pull all the latest changes, the hg merge command will get you there.

The simplest case is when you're using clones to implement branching (since that's the use case Mercurial is designed around). Assuming you've turned on the built-in fetch extension in your .hgrc / Mercurial.ini:

cd ~/src/development
# hack hack hack
hg commit -m "Made some changes"
cd ../production
hg fetch ../development

If you're using local branches:

hg update -C development
# hack hack hack
hg commit -m "Made some changes"
hg update -C production
hg merge development
hg commit -m "Merged from development"
like image 74
Erin Dees Avatar answered Oct 02 '22 14:10

Erin Dees