Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Mercurial, is there any way (aside from "Cherry picking") to push a changeset without also pushing changesets associated with a different head?

In the answer to this question, Ry4an states that "you cannot push Changeset2 without pushing Changeset1".

This certainly makes sense if the repository looks like this:

+ Changeset2
|
+ Changeset1
|
+ Original

However it doesn't seem to make as much sense in the following scenario, which is what I currently have:

+ Changeset2
|
|   + Changeset1
|  /
| /
+ Original

Ideally, I want to be able to push just Changeset2 back to the repository I initially cloned from. Mercurial doesn't seem willing to let me do that. It's insisting I push Changeset 1 also... which is not allowed as it would create a new head in the original repository. Obviously I could "Cherry pick", or create a patch to apply on the original repository but that seems clunky. Am I missing something?

Update: I should probably have mentioned in my initial question that I was trying to perform the operation from the TortoiseHg GUI. As Niall C. correctly identified in his answer, the Mercurial command line allowed me to accomplish what I needed, however I would still be interested in learning if there is any way to accomplish the same operation from the GUI.

like image 395
Richard J Foster Avatar asked Oct 20 '10 14:10

Richard J Foster


2 Answers

If you're using hg push without any command-line option, it will try to push every changeset in your local repository that doesn't exist in the remote repository. If you use the -r / --rev option, it will just push that revision and its ancestors. In your case, you would need to do:

hg push --rev Changeset2

See hg help push for full details.

like image 144
Niall C. Avatar answered Sep 20 '22 00:09

Niall C.


For the UI lovers who like pictures:

  1. In TortoiseHg click on Detect outgoing changes to button. enter image description here

  2. Click right mouse button on revision you want to push.

  3. Choose Push -> Push to Here. enter image description here

Result: You will push only revision selected rather than everything. enter image description here

Hope this saves you some time.

like image 33
Matas Vaitkevicius Avatar answered Sep 23 '22 00:09

Matas Vaitkevicius