I have a central Mercurial repository containing a history cloned from a SVN repository using hgsubversion. I have pulled the additional commits made to the SVN repository since the original hg repo was cloned; these are currently in the default branch.
I also have a named branch. I have cloned this branch (using hg clone -b mybranch
) to my local system. Now I want to grab the changes that exist only in default and make them available in my named branch. The obvious way I see to do it is to do a hg update mybranch
on the repo, then hg merge default
and commit. This seems perilous--if I forget to update back to default after I'm done, all future pulls from SVN will pull changes into mybranch.
I have also considered that perhaps I should not have specified mybranch when I cloned the repo, but cloned the entire repo and just updated to mybranch locally. Thus I could pull the changes in default to my local clone and do the merge there.
What's the right answer here? Do it on the shared repo and just be careful? Clone everything and manage branches locally? Or is there an easier solution I'm missing?
From the main menu, select Hg | Mercurial | Update to. In the Switch Working Directory dialog that opens, specify the target working directory: To switch to another line of development, choose Branch and select the desired branch from the list.
Named branches If no branch name was set, Mercurial assigns the branch name "default". So the name of the default branch in a repository is "default" (which, for example, is not displayed when doing a hg log). Mercurial branch names may be used for whatever reasons users want.
First, we need to move back into the main branch, which is accomplished using the “hg update” command. Then, we run the “merge”command, specifying the name of the branch we'd like to merge from. Finally, we commit the changes. The changes are now present in the main branch.
In general with Mercurial, anytime that I do something that I think might cause issues, I clone the repo and try it out there. Then I can either choose to push those changes back in or perform the action on the real repository. Either way I have the option of failing and not causing any damage. Clones can be thrown away, you don't have to keep them around if you screwed up.
Do it in the shared repo and be careful. Or clone the entire shared repo, do the merge there, and then push to the branch-only clone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With