Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move some changeset to a new branch in mercurial

I want to move a changeset from one branch to another. Basically, I currently have:

A -> B -> C -> D # default branch 

And I want:

A # default branch  \-> B -> C -> D # some_new_branch 

Where some_new_branch does not exist yet. I am used to git, so I guess there is a simple "mercurial" way I am missing.

like image 372
David Cournapeau Avatar asked Feb 08 '10 05:02

David Cournapeau


People also ask

How do I change my branch on mercurial?

From the main menu, select Hg | Mercurial | Update to. In the Switch Working Directory dialog that opens, specify the target working directory: To switch to another line of development, choose Branch and select the desired branch from the list.

How do I revert a changeset in Mercurial?

Revert changes already committed To backout a specific changeset use hg backout -r CHANGESET . This will prompt you directly with a request for the commit message to use in the backout. To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.

What is mercurial changeset?

A changeset (sometimes abbreviated "cset") is an atomic collection of changes to files in a repository. It contains all recorded local modification that lead to a new revision of the repository. A changeset is identified uniquely by a changeset ID. In a single repository, you can identify it using a revision number.


1 Answers

One way is to export a patch for B,C,D; update to A; branch; apply patch:

hg export -o patch B C D hg update A hg branch branchname hg import patch 

To remove B,C,D from the default branch, use the mq extension's strip command.

like image 191
Mark Tolonen Avatar answered Sep 24 '22 05:09

Mark Tolonen