Question

We're using Kiln and Fogbugz; Kiln is supposed to seamlessly allow git and hg to work together. However, we've run into an issue where git branches are treated like bookmarks in mercurial; we didn't catch this in our repo until changes had been pushed, and now the branches are a bit polluted.

I have public changesets in our default branch that should be in a custom branch. I can back them out, but I need to reapply them to the other public branch. I'm worried about rebasing because these are public changes.

What's the best way to handle this situation?

Edit: I thought I might be able to convert the changesets to a patch using mercurial queues, but the changesets aren't mutable since they're public. I also can't do hg strip for similar reasons.

Was it helpful?

Solution

In Mercurial, you use hg graft to copy (also sometimes called cherry pick) changesets from one place to another. It is frequently used to backport a bugfix to a maintenance branch when the bugfix was committed on the wrong branch by accident.

You use it like this:

$ hg update correct-branch
$ hg graft your-commit

This will recreate your-commit as a child of correct-branch, similarly to importing your-commit into MQ, popping the patch, updating to correct-branch and pushing the patch. The advantage of graft is that it will use three-way merges internally to give you much better conflict resolution. It is really the same way that hg rebase works.

OTHER TIPS

I'd like to promote torek's comment to a full-fledged answer to make it more visible.

As he notes, the hg phase command (with the --force flag) can repair the situation when mercurial thinks the changeset has been made public. Of course you want to make very sure you're right about whether it has been shared first.

I ran into a glitch where mercurial marked an unpushed branch as public, and this made it easy to fix with qimport (or could have used strip.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top