Storing individual named branches in mercurial without merging them

This is my first time I used DVCS, and also as a lone developer, the first time I really used branches, so maybe I missed something.

I have a remote repository from which I pulled out files and started working. Changes have been pushed to the remote repository, and of course this simple script works just fine.

Now that my web application has some stable features, I would like to start deploying it, and so I cloned the remote repository into a new branch / stable directory outside of my working directory for the default branch and used:

hg branch stable 

to create a new named branch. I created a bunch of deployment scripts that are only needed by a stable branch, and I completed them as needed. It worked again.

Now that I’ve returned to my original working directory to work on some of the new features, I found out that Mercurial only insists that one of them is in the remote repository. In other words, I would have to merge the two branches (default and stable), adding my default branch to the unfinished deployment script to go to the main repository. This can get worse if I had to make changes to the file in my stable deployment branch.

How to save my named branches separately in Mercurial? Do I need to create two separate remote repositories? In this case, the named branches lose their value. Did I miss something?

+7
branch mercurial
source share
4 answers

After reading the section again in the forked development in the Mercurial book, I came to the conclusion that for me personally it is best practice to have separate shared repositories, one for each branch. I was on a free account at bitbucket.org, so I tried to force myself to use only one shared repository that created the problem.

I beat the bullet and got a paid account so that I could keep a separate shared repository for my stable releases.

+3
source share

Use hg push -f to force the creation of a new remote head.

The reason push will not do this by default is that it is trying to remind you to pull and drain if you forget. What you do not want is:

  • We are checking revision 100 of the named branch "X".
  • You execute locally and click.
  • I execute locally and click.

Now the X branch looks like this in the remote repo:

 --(100)--(101) \ \---------(102) 

With what head should a new developer appear if they check a branch? Who knows.

+11
source share

You wrote:

I found out that Mercurial insists only that there is only one chapter in the remote repository.

Why do you think this is so?

From the help for hg push :

By default, push will refuse to start if it detects a result. increase the number of heads removed. This usually indicates the client forgot to pull out and drain before clicking.

If you know that you are intentionally creating a new head in a remote repository, and this is desirable, use the -f flag.

+2
source share

I came from git, expecting the same. Just clicking on the top looks like it could be one approach.

hg push -r tip

+1
source share

All Articles