开发者

Retroactive named branching in Mercurial

开发者_运维问答

Is there a way to associate a bunch of Mercurial changesets with a named branch after they have been committed, i.e. retroactively ?


I just wanted to do this, and here’s the solution I found. A year has passed since the question was originally asked, this might explain why I can now find a solution. It has the disadvantage that you create an extra revision in the process, but this wasn’t too bad for me.

First, you go back to where you want to create the branch. In my case, I actually wanted to start a new root (because I wasn’t very sensible when I started the repository, but anyways), so I’m updating to null. You probably want to start somewhere else, it depends on your situation.

$ hg update null

Then, create the branch.

$ hg branch blah
$ hg commit -m "Created blah branch."

Then, we rebase all the commits we made onto our new branch:

$ hg rebase -s SOURCE -d DEST

The SOURCE here should be the first commit you made in the commits you want to create the branch from, and the DEST should be the commit where the branch was created (the one we committed above).


No, branch names are part of the changeset (it's really like a label you add to the commit), it means the changeset hash depens on the branch name.

So the only way to change it retroactively is by rewriting history (which doesn't play well if you pushed your changes elsewhere, since you'll have to rewrite every repo which has the changes).

To rewrite history, you could use for example mq.


Not a complete solution but, without re-writing history; you could tag the last change set in the unnamed branch. If you never rebranch from this the tag should surfice. If you do need to rebranch you can move on to a named branch after the tagged changeset.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜