6

Is there a way to have transplant a single changeset without commiting? I'd like to be able to review the changes prior to doing a commit.

Robert Jeppesen
  • 7,837
  • 3
  • 35
  • 50

2 Answers2

8

hg transplant always results in a new changeset in your repository.

However, you could:

  1. Use hg export and hg import --no-commit instead OR
  2. Use hg transplant and then hg strip if you don't like the changeset
Botje
  • 26,269
  • 3
  • 31
  • 41
Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
3

Found this question when searching for "graft without commit".

I've found I can do what I want by updating to the changeset where I want the changes to be on top of, then using the "hg revert" command.

So if I have changeset "R1" then I commit a "R2" I can put the R2 changes back into the working directory by doing:

  • hg update -r R1 <-- (this puts your working directory in exact state you want to start from)
  • hg revert --all -r R2 <-- (this applies the changes in R2 to the working directory, without committing those changes)

You can then strip the R2 changeset if you want or do whatever you want.

Shorn
  • 19,077
  • 15
  • 90
  • 168
  • Wouldn't `hg revert --all -r R2` do much more than cherrypick `R2` into the current changeset without committing? IIUC, it would completely overwrite any changes made to the files in `R1`, replacing the entire files with whatever contents they have in `R2`? – max Sep 02 '18 at 21:21