Switching branches with a default branch in Mercury

I work in a repo, we created a named branch at some point in order to try a different approach to a specific problem. We continued to work in the default branch.

Now that the named branch has matured, so to speak, we would like to make this branch by default and give a different name to the default branch (old).

Is something like this possible?

I found this question, Mercurial: can I rename a branch? , and I can rename the default branch successfully, but then when I try to rename the name of the default branch, it fails with an error

abort: a branch of the same name already exists 
+4
source share
1 answer

Yes, you can.

You need to close all branches and then give them the name you want

PS: it looks like you just need to add the -f flag to the branch command

Scenario example

 hg init echo "123" > file hg addremove hg commit -m "init default" hg branch new echo "new" >> file hg commit -m "init new" hg up default echo "default" >> file hg commit -m "default 2nd" hg commit --close-branch -m "close default" hg up new hg commit --close-branch -m "close new" hg branches # none hg log # see where to update if haven't saved id/hash somewhere hg up 3 # this changset was the "close default" one hg branch new -f hg commit -m "new new" hg up 4 # the changeset we closed "new" at hg branch default -f hg commit -m "new default" 

Result:

enter image description here

 >hg log -G o changeset: 6:af87a53292cf | tag: tip | parent: 4:700a73ac7cad | user: Ivan Kurnosov | date: Tue Jun 05 17:22:27 2012 +1200 | summary: new default | | @ changeset: 5:4ee990605ba1 | | branch: new | | parent: 3:6ebccfc3e630 | | user: "Ivan Kurnosov | | date: Tue Jun 05 17:18:01 2012 +1200 | | summary: new new | | o | changeset: 4:700a73ac7cad | | branch: new | | parent: 1:4a149d3fe86e | | user: "Ivan Kurnosov | | date: Tue Jun 05 17:15:18 2012 +1200 | | summary: close new | | | o changeset: 3:6ebccfc3e630 | | user: "Ivan Kurnosov | | date: Tue Jun 05 17:14:49 2012 +1200 | | summary: close default | | | o changeset: 2:92669a82423b | | parent: 0:05657f61324b | | user: "Ivan Kurnosov | | date: Tue Jun 05 17:13:07 2012 +1200 | | summary: default 2nd | | o | changeset: 1:4a149d3fe86e |/ branch: new | user: "Ivan Kurnosov | date: Tue Jun 05 17:12:30 2012 +1200 | summary: init new | o changeset: 0:05657f61324b user: "Ivan Kurnosov date: Tue Jun 05 17:11:51 2012 +1200 summary: init default 
+6
source

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


All Articles