1

For some reason, I have following situation:

enter image description here

Now I want to get rid of default_2 and fast-forward default to rev 89. But when I do

hg up -r default
hg transplant 61:89

or

hg transplant -b default_2

Mercurial (1.8.2+20110401) just updates my working copy to rev 89. With mq extension it looks like I have to specify all intermediate revisions one-by-one.

So the questions are:

  1. Why doesn’t transplant work? (It’s recommended here: https://www.mercurial-scm.org/wiki/RebaseProject#When_rebase_is_not_allowed)
  2. Is there a way to fast-forward without much pain?
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Niki Tonsky
  • 1,327
  • 11
  • 19

3 Answers3

4

Using Mercurial Queues, you can:

hg qinit
hg qimport -r 61:89
hg qpop -a           # unapply all patches
hg up default        # return to your default branch
hg qpush -a          # apply all patches on default
hg qfinish -a        # move applied patches into repo history

NOTE: This assumes that revisions 61:89 have not been pushed to a public repo. The given mq commands will modify history. If these revisions have already been pushed, then it would be best to simply close the default2 branch and then merge default2 into default.

Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
  • Thank you very much! That works, didn’t find anywhere in the docs that qimport understands ranges. – Niki Tonsky Apr 19 '11 at 14:02
  • @Nikita: You are welcome. In newer versions of Mercurial (>=v1.7), the `-r` option supports a functional language for selecting sets of revisions. See `hg help revsets` for details (http://www.selenic.com/hg/help/revsets). Also, if my answer was good, please mark it as accepted. – Tim Henigan Apr 19 '11 at 14:24
  • Wow, thanks again! By the way, don’t you know what’s the problem with `transplant`? Official documentation recommends it here: http://mercurial.selenic.com/wiki/RebaseProject#When_rebase_is_not_allowed – Niki Tonsky Apr 19 '11 at 14:32
  • @Nikita: I just started looking at that now. It is not working for me at the moment either, but I have an unstable version of Mercurial installed. – Tim Henigan Apr 19 '11 at 14:39
1

try:

 hg branch --force default

it recreate new branch named default

madjardi
  • 5,649
  • 2
  • 37
  • 37
0

As of Mercurial 2.0 you can use the graft command (built-in command largely replacing the transplant extension):

hg graft 61:89

See also a related question on differences between graft and transplant.

Note that the reason Mercurial doesn't support actual fast-forwards a la Git between named branches is that the branch name is part of the Mercurial commit object. See also this article detailing the Mercurial branch model.

Community
  • 1
  • 1
kynan
  • 13,235
  • 6
  • 79
  • 81