Gili
Gili

Reputation: 89983

How to move some revisions from one branch to another?

hg convert --branchmap allows moving all revisions in a branch to a different branch. In a branch with multiple heads (e.g. one path leads to a "closed branch") how do I move some of the revisions to a different branch while leaving others unchanged?

Upvotes: 1

Views: 57

Answers (2)

StayOnTarget
StayOnTarget

Reputation: 12988

Use a combination of branchmap and splicemap options to hg convert. Possibly in more than one step, depending on exactly what you need to do.

Upvotes: 0

Gili
Gili

Reputation: 89983

According to Pierre-Yves David

You should be able to achieve this using "histedit". Use the "edit" action on the first changesets and set up branch name before committing.

So for example, say we have:

@  changeset:   3:acd042300874
|  tag:         tip
|  user:        [email protected]
|  date:        Tue Sep 27 11:22:33 2016 -0400
|  summary:     commit4
|
o  changeset:   2:6cd4bf5a3e25
|  parent:      0:7f1fbf9d8623
|  user:        [email protected]
|  date:        Tue Sep 27 11:22:33 2016 -0400
|  summary:     commit3
|
| o  changeset:   1:5cf7adbb92ea
|/   user:        [email protected]
|    date:        Tue Sep 27 11:22:32 2016 -0400
|    summary:     commit2
|
o  changeset:   0:7f1fbf9d8623
   user:        [email protected]
   date:        Tue Sep 27 11:22:32 2016 -0400
   summary:     commit1

and we want to move revisions 2, 3 onto a different branch we would do the following:

  1. hg update 3
  2. hg histedit 2
  3. Change both revisions from "pick" to "edit"
  4. hg branch "new-branch"
  5. hg commit -m "old commit message for rev2"
  6. hg histedit --continue
  7. hg commit -m "old commit message for rev3"
  8. hg histedit --continue

Upvotes: 1

Related Questions