Problem with Mercurial push

I have a problem with the hg push command. What I did - firstly, I created two branches hot-fix-1 and hot-fix-2 made some changes in each branch, merged it with the default and closed these branches with the command:

 hg commit --close-branch 

If I run hg branches , I have the following output:

 default 29:e62a2c57b17c 

hg branches -c gives me:

 default 29:e62a2c57b17c hot-fix-2 27:42f7bf715392 (closed) hot-fix-1 26:dd98f50934b0 (closed) 

Thus, hot-fix-* seem to be closed. However, if I try to click on the changes, I will receive the following error message:

 pushing to /Users/user1/projects/mercurial/mytag searching for changes abort: push creates new remote branches: hot-fix-1, hot-fix-2! (use 'hg push --new-branch' to create new remote branches) 

and it doesn't matter which command I use hg push -b . or hg push -b default
So the question is how can I move these changes to the repository without creating new branches.

PS I worked with git and hoped that a similar branching model could be used in Mercurial. Thanks

+4
source share
3 answers

Firstly, as many others have pointed out, using the named branch for short work is not recommended. Named branches are primarily designed for long-lived functions or for release management.

Given that you are in this situation, there are several options available. They are all about changing the story (as you are obviously trying to change something that you did).

One of them is just to push the branches as they are, learn from experience and move on. If the rest of the command is ok with this, then this is the case of adding -new-branch to your push command.

If the rest of the team or you really want the story clear, then you will need to dig deeper.

If you don’t click, then be sure to clone your current repo. So you have a copy of the original work to go back.

Here I see two main approaches. Remove merges and reconnect your default branches. This will save you from the named branches or transplant / transplant your changes. Both will have the same end result, but the implementation is slightly different.

If you just want to use graft , now it is a built-in function starting with HG 2.0. It replaces the transplant plugin and works much better since it uses your regular merge tool if there are conflicts.

To use it, update the default branch. Then use the command:

 hg graft -D "2085::2093 and not 2091" 

the line after -D is the hg revision selection request. In your case, you will most likely need {{start} :: {end} ', where start is the set of changes at the beginning of the branch, and end is the end of the set of changes to the branch (ignoring merging).

If you have made several mergers, you will need to select and select the changes in accuracy.

Another option is to remove the final merges and use the rebase command, which is part of the mq plugin.

You will need to delete your plugin changes in order to get rid of them, and then update to the end of the branch that you want to save. Select the start of the first named branch and reinstall. This will change the origin of the branch (if you are familiar with Git, this is very similar to rebooting).

Then repeat for the second branch. You should now have one long branch with the default name.

+5
source

Just do:

 hg push --new-branch 

He will send these branches, but they will also be closed on the receiving side, so no one should bother.

See my commentary on why Named Branches are best preserved for long-lived objects, such as "stable" and anonymous branches, bookmarks or clones, more suitable for short things like fixes and new features.

+3
source

Your hot-fix changes have been made to branches. Regardless of whether a branch is active or closed, it exists.

To push changes to the server (without rewrite history), you should use the --new-branch option (e.g. hg push -new-branch`).

Since you merged the default branches, you still have only one head left (as you saw in your local repo).

If you really can't live pushing branches to the server, then you should rewrite your local history as suggested in the answer by Mikezx6r .

In addition to the methods he mentioned, you can also import changes to the patch queue and apply them to the end of your default value.

+2
source

Source: https://habr.com/ru/post/1343798/


All Articles