earthling
earthling

Reputation: 5264

Pushing single changeset in Mercurial when multiple are available

I have 5 outgoing changesets available to push from my local Mercurial repo, and I only want to push one of these at this time. This one changeset lies in the middle of all available.

For example I have the following revisions:

and I only want to push 6545. Any easy way to do this?

Upvotes: 7

Views: 7774

Answers (3)

alexis
alexis

Reputation: 50190

What you want is not possible. A revision must put a repository in a definite state, but if you could push 6545 and the remote repository updated to it, it would not include the changes from earlier (not pushed) revsets. This goes against the core design of mercurial. What you can do is:

a) distribute a diff (patch) that contains the same changes as rev 6545. You can do this via hg diff or in other ways, but applying the patch is not inherently connected to your rev 6545: it is a separate revision that "happens" to make the same changes. If you're lucky, they can be merged in the future without problems. Or

b) rewrite your history, temporarily (with the mq extension) or permanently (with the help rebase or other extensions) so that 6545 is placed immediately after the already-commited revisions. You can then push it like any other revision whose ancestors have already been pushed.

Upvotes: 1

Steve Kaye
Steve Kaye

Reputation: 6262

You could use the Mercurial Queues extension to do this. You may need to enable the mq extension which is detailed on the linked page.

You would import all the revisions into the queue, pop them all off the stack and then apply the one that you want before pushing and then applying the rest. Something like this:

> hg qimport --rev 6639
> hg qimport --rev 6543:6546
> hg qpop --all
> hg qpush --move 6545.diff

Here you might have to resolve conflicts

> hg qfinish --applied
> hg push
> hg qpush --all

Again, might need to resolve conflicts here.

This has left your repository with revision 6545 applied and pushed (but with a different revision number now) and the rest of your changes applied and not pushed.

Upvotes: 2

zerkms
zerkms

Reputation: 254916

You can only push the consecutive list of changesets up to the required.

So

hg push -r 6545

will push 6543..6545.

And you cannot push just 6545 because without preceding changesets its changes make no sense.

Upvotes: 17

Related Questions