Fast-forward branch in mercurial
For some reason, I have following situation:
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 t开发者_运维知识库o rev 89. With mq
extension it looks like I have to specify all intermediate revisions one-by-one.
So the questions are:
- Why doesn’t
transplant
work? (It’s recommended here: https://www.mercurial-scm.org/wiki/RebaseProject#When_rebase_is_not_allowed) - Is there a way to fast-forward without much pain?
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
.
try:
hg branch --force default
it recreate new branch named default
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.
精彩评论