0

I have a branch with several shelves and this branch is now out of developement because we branched a new one from it. Now I need to take over my shelved changes without modifying the old branch to the new one. What is the easiest way?

I know I could unshelve, manually take over the changes and revert the old branch, but that is tedious. Any better solution?

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181

2 Answers2

0

This will take a few steps per changeset.

In the old branch directory, do:

bzr unshelve --keep ID

In the new branch directory, do:

bzr merge --uncommitted OLD_BRANCH_DIRECTORY
bzr shelve --all -m MESSAGE

Back in the old branch, do:

bzr revert

to get it back to its original state.

The unshelve operation puts the changes in the working directory of the old branch, the merge transfers them to the working directory of the new branch, the shelve operation does its usual work, and the revert resets the old branch to its original state.

Choose ID, OLD_BRANCH_DIRECTORY, and MESSAGE as needed. Repeat for each shelved changeset.

Reimer Behrends
  • 8,600
  • 15
  • 19
  • Thanks for your suggestion, but this is what I meant by the additional description sentence about unshelving etc. My hope was I could get this a bit simpler. But maybe that's the best I can get. – Mike Lischke Nov 07 '13 at 09:12
  • I'm afraid this may be your best option (of course, you could still wrap it in a script, but that'd probably take longer to write than doing it manually). You could try to copy the `.bzr/checkout/shelf` directory and its contents to the new branch, but I have no idea if that's going to work cleanly. – Reimer Behrends Nov 07 '13 at 11:27
0

Maybe the cleanest and best way is to create a replica of the old branch, convert the shelves to proper commits, and merge them. For example:

cd /path/to/repo
mv oldbranch work            # we will unshelve in "work"
bzr branch work oldbranch    # the replica, but without shelves
cd work
bzr unshelve
bzr commit -m 'some change'
bzr unshelve
bzr commit -m 'another change'
cd ../targetbranch
bzr merge ../work

Another way, but less clean, is perhaps using bzr unshelve --preview and the patch command:

bzr unshelve --preview -d /path/to/oldbranch | patch -d /path/to/targetbranch

But I really recommend the first option.

janos
  • 120,954
  • 29
  • 226
  • 236