Razican
Razican

Reputation: 727

Mercurial: How can I import only some changesets from a repository?

I have a repository, called "my project" based in a framework called "framework". The two of them have each it's repository, unrelated between them, with each branches and tags. I want to receive "framework"'s updates in my repository, but only from "default" branch and not from others. And, of course, I do not want to have "framework"'s tags in my repository, as it is a totally different project.

I have Mercurial HG, and I would like to be able to pull changes from "framework" repository directly from my "Manage repository" page.

Furthermore, I only want to download latest changesets, since I started my project not long ago. And It would be perfect if I could rename the "framework"'s default branch to other name in my repo, e.g. "Framework Changesets".

Note: I do not have write access to the "framework" repository.

I tried to do what mercurial wiki said:

hg pull -f -r default "framework"

It was OK, until I realised I had downloaded all the tags from the "framework" repository, and I had downloaded all the changesets from the remote repository. Furthermore, when in TortoiseHG->Configuration->Synchronization I put the "framework" repository as a remote repository for that project, and pulled from the remote repository, I got all the branches from that repository.

Of course I wasn't able to change default branch name, and updated my default branch, even though I tried to use hg convert --branchmap (but I didn't know how to use it).

Is there any solution to my problem? or even a partial solution?

Upvotes: 3

Views: 5721

Answers (2)

apm
apm

Reputation: 535

We can specify the branch name by appending branch name with a # symbol in the clone url.

e.g.

hg clone --verbose https://user@cloneurl/my_product#MY_BRANCH "C:\myCode"

Upvotes: 0

dls
dls

Reputation: 4146

I think you can address this issue through a combination of these things:

Pulling specific branches

Using the command line: hg pull -r <branch name>

Using TortoiseHg v1.1.X:

  1. Check for incoming changesets by using the button labeled Download and view incoming changesets
  2. Right-click on the tip of the branch you want to pull and select Pull to here
  3. Reject the rest of the changesets using the Reject button

Removing existing tags

You can always hand-edit the .hgtags file to remove tags created on the "framework" branch, but I don't know of a way to pull changesets without the tags.

Changing branch name

Using the mq extension you can change the named branch that your new "framework" changesets live on. See answer to "Apply patches in branch" for instructions on how to do this in TortoiseHg v1.1.X, as well as the CLI. The basic idea here is to create a named branch with the name you want, import all of the "framework" changesets you pulled into a patch queue, and then apply them to the new named branch. They will shed the branch name from "framework" and use the branch name of the branch you applied them to.

If you are going to pull from "framework" more than once, you would need to use the patch queue to move only the new changesets with each pull. It should be easy to see which changesets you haven't moved yet.

Upvotes: 6

Related Questions