Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial : Updating a Fork with Changes from the Master Repository

Tags:

mercurial

I'm following this post Codeplex: Updating a Fork with Changes from the Master Repository but it seems like it doesn't work for me. As I'm new to Mercurial, I might be missing something..

Scenario

Here is the URLs of the main repository and my fork. I created a fork from main repository a few months back.

  • Main Nuget repository : https://hg.codeplex.com/nuget.
  • My fork repository : https://hg.codeplex.com/forks/michaelsync/msyncwillmakeyoubetter.

Problem

I can't update my fork with the changes from master repository.

Steps taken

Here is the steps that I tried to do but it didn't work.

PS C:\michael sync\git\nuget> hg clone https://hg.codeplex.com/forks/michaelsync/msyncwillmakeyoubetter
destination directory: msyncwillmakeyoubetter
requesting all changes
adding changesets
adding manifests
adding file changes
added 2231 changesets with 13584 changes to 3800 files
updating to branch default
1205 files updated, 0 files merged, 0 files removed, 0 files unresolved

PS C:\michael sync\git\nuget> cd .\msyncwillmakeyoubetter

PS C:\michael sync\git\nuget\msyncwillmakeyoubetter> hg pull https://hg.codeplex.com/nuget
pulling from https://hg.codeplex.com/nuget
searching for changes
adding changesets
adding manifests
adding file changes
added 301 changesets with 2574 changes to 838 files (+1 heads)
(run 'hg heads' to see heads)

PS C:\michael sync\git\nuget\msyncwillmakeyoubetter> hg commit -m "sync the changes from main respo to my fork"
nothing changed

PS C:\michael sync\git\nuget\msyncwillmakeyoubetter> hg push
pushing to https://hg.codeplex.com/forks/michaelsync/msyncwillmakeyoubetter
searching for changes
abort: push creates new remote branches: 1.6, 1.6.1, 1.7!
(use 'hg push --new-branch' to create new remote branches)

What I don't understand is that how come there is no change after pulling the code from master repository. It said nothing changed when I tried to commit.

I checked these posts How can I get the changes from a "master" repository in mercurial for a project hosted on google code? and Mercurial - how to fetch latest changes from parent of fork? but couldn't make it work until now.

like image 667
Michael Sync Avatar asked Feb 21 '23 04:02

Michael Sync


1 Answers

First of all, it is really important to understand what exactly the various commands you used do :

  1. pull : retrieve the changes from a repository, but don't apply them to the working copy
  2. commit : apply the changes on the working copy to the local directory
  3. push : push all change sets in the local repository to the remote one
  4. update (which you didn't use) : update your working copy to a specific changeset from the local repository

You'll notice that I use two different terms, working copy and repository.

The repository is all the change sets available, with the various branches, heads, etc.

The working copy is the files you actually see in your file explorer, they can be to totally different state than the last changeset in the repository.

So, once you did your pull, if you want to "apply" the changes to your working copy, you must do an update, Alternatively, you can also du hg pull -u. If you made some changes since the last pull, you may have to merge instead of updating, if you look at the documentation you've linked, they're doing a merge (step 3).

If the update was successful, no need to do a commit, the changes are already in your local repository. If you had to do a merge, a commit will be necessary to acknowledge the changes you made.

Concerning the push part, you're creating new branches by doing so like stated by the error message. By default, Mercurial don't push changesets creating new branches, you must use the stated command : hg push --new-branch or push a branch specifically hg push mybranch

I hope my explanations are clear enough, otherwise feel free to comment. I also recommend you read some tutorial about Mercurial, for example this one : http://hginit.com/

like image 72
krtek Avatar answered Apr 29 '23 04:04

krtek