user1540714
user1540714

Reputation: 2089

TortoiseHG: Only pull selected changesets?

I have 2 repositories A and B. I make 5 changes to A, but only 2 of them should also appear in B. So this is what I tried:

  1. Pushed the 5 changes to repo A
  2. Changed the path of repo B to that of repo A
  3. Clicked the "Check for incoming changesets" button for repo B

Now I see the 5 changes I made for repo A. This is where I am stuck, how can I only get 2 of the 5 changesets now? I tried "Pull to here", but this does not work in my case, it gets all changesets below the one I selected.

How can I get for example the first and third changeset from the list? Possible at all?

Thanks! :)

Upvotes: 0

Views: 435

Answers (2)

HLundvall
HLundvall

Reputation: 193

When you pull changesets between repositories you cannot skip changesets in between. If a changeset has different parents in two repositories, it is not the same changeset.

You can accomplish what you are after by exporting patches of the changesets you want and then import them into the other repository. That way, you have the changes you want from repo A in B, but the changesets will not have the same nodeid in the two repositories.

Upvotes: 2

Mark Tolonen
Mark Tolonen

Reputation: 178115

It sounds like A and B were clones of the same repository. If that is the case, branching is probably what you need. If you have a history where A contains:

C:\example>hg glog --template "rev{rev}:{desc}\r\n"
@  rev6:change7
|
o  rev5:change6
|
o  rev4:change5
|
o  rev3:change4
|
o  rev2:change3
|
o  rev1:change2
|
o  rev0:change1

If your B was originally just rev0 and rev1 and you wanted rev3 and rev5 added to it, you can just update to rev1 and graft rev3 and rev5 onto it:

C:\example>hg update 1
0 files updated, 0 files merged, 5 files removed, 0 files unresolved

C:\example>hg glog --template "rev{rev}:{desc}\r\n"
o  rev6:change7
|
o  rev5:change6
|
o  rev4:change5
|
o  rev3:change4
|
o  rev2:change3
|
@  rev1:change2
|
o  rev0:change1

C:\example>hg graft 3 5
grafting revision 3
grafting revision 5

C:\example>hg glog --template "rev{rev}:{desc}\r\n"

@  rev8:change6      <--- contains change 1, 2, 4, 6
|
o  rev7:change4
|
| o  rev6:change7    <--- contains changes 1-7.
| |
| o  rev5:change6
| |
| o  rev4:change5
| |
| o  rev3:change4
| |
| o  rev2:change3
|/
o  rev1:change2
|
o  rev0:change1

To avoid duplication of changesets and a little pre-planning, the changes that need to be on both A and B branches can be checked into B and merged into A, whereas changesets that only belong on A can be directly checked into A:

C:\example>hg glog --template "rev{rev}:{branch}:{desc}\r\n"

@  rev8:A:change7     <--- contains changes 1-7.
|
o    rev7:A:Merge
|\
| o  rev6:B:change6   <--- contains change 1, 2, 4, 6
| |
o |  rev5:A:change5
| |
o |  rev4:A:Merge
|\|
| o  rev3:B:change4
| |
o |  rev2:A:change3
|/
o  rev1:default:change2
|
o  rev0:default:change1

Upvotes: 1

Related Questions