Showing posts with label Mercurial. Show all posts
Showing posts with label Mercurial. Show all posts

Mercurial Eclipse

In Eclipse, if you want to add a project into Mercurial:

Team->Share Project....

I got a problem with one project, and I could not apply "Share Project" into it. The fix is: Team->Disconnect, then apply "Share Project".

DropBox + Mercurial: A perfect solution for code development

Ever had the problem copying codes over from one machine to another, most likely, home vs work? DropBox solved the problem syncing the codes between different machines, while Mercurial (without Push) provides version control abilities.

Mercurial Notes (2)

This is from my colleague Esteban:

When you are working with Mercurial, it may help you understand that the work you are doing in your local repository is being done on your own personal branch (an unnamed branch).

In the meantime, other people continue making changes to the original branch on the master repository.

When you try to synchronize your repository with the master you discover that your branch has diverged from the main branch (as it happens if somebody pushes changes before you).

The best strategy to get back in sync with the master repository is to move all your work in your personal branch, to the top of the history (the top of the current history in the master repository).

Mercurial and the Eclipse plugin let you do this with a command called "rebase".

Steps to synchronize your committed changes with the master repository:
  1. pull and update to the latest version
  2. rebase
  • select the first change you committed in your personal branch
  • select the current tip of the branch you are working with
  • resolve any conflicts
  • commit
     3. push your changes to the server

Why do you get two heads after pulling from the master repository?






















Rebasing:



Mercurial Notes

This is an Email from my colleague Gareth:


Ian explained this a little last night.  Since this is going to come up a lot, I wanted to explain what the dialog options are.

You'll get this dialog if you've made changes to a repository at the same time as someone else.  (You committed changes to your local repository, then went to push them.  Someone else had sneaked in and pushed changes ahead of you that you don't have.)  You'll get this dialog.

If you imagine your repository, this is what it looked like after you committed your changes "L1" and "L2":

But some other developer (probably with a few extra cups of coffee in them because boy they did it awfully fast) made changes "R1" and "R2" at the same time and pushed them to the main repository ahead of you.  The dialog is saying you've got a situation like this:


There are three ways to handle it.  One is to force your changes anyway and split into two heads.  NEVER DO THIS.  It's not what we want.

The easiest thing to do is "Rebase", and it's always the first thing you should try. What "Rebase" does is looks at the files involved.  If you've both worked on completely different files, it will just update your repository to take the "R1" and "R2" changes, then stick your changes on top:

Now you can push your changes with no problem.   In the graph of the branch, this simply adds your changes as a new node after  that "coffee'd up" developer.  Since most of the time we'll all be working on different files, this is the most common scenario, and how we should try to handle it.

OK, but what if Mr/Mrs coffee worked on the SAME files as you did.  What a jerk!  Rebase doesn't work.  You get an error that a merge is required.  OK, no biggie.  Now you have to do a merge.  I'm not sure how the dialogs work and will update this when I find out, but you want to get to that second option "Merge two heads".

If you've changed different parts of the same file, the merge can be done automatically.  If not, you've got to handle the conflicts in the UI just like we did all the time in IDEA and CVS.  Once we're done and happy with the merge, we commit the updated files and push our changes.  The graph now looks like this, with "M1" being the combined streams of work.

Hope that helps.  Please let me know if there's problems with the explanation, or your experience differ with what I've described above.  Happy "Rebasing".

Thanks,

Gareth

Mecurial

1. install TortoiseHg
2. If you type hg in cmd, it's not working, make sure C:\Program Files\TortoiseHg in path.
2. use command
In C:\Users\hliu\mercurial.ini,
add something like

[ui]
username = hliu <haiboliu@dovetailsystems.com>

Otherwise, when you type hg commit, it will have an error

"abort: no username supplied (see "hg help config")"

3. create a repository at your local for your own use
go to top level of your coeds
hg init
hg add
hg commit

http://hginit.com/