Differences between revisions 1 and 2
Revision 1 as of 2012-08-23 11:48:34
Size: 8304
Comment: Migrated from aragost.com
Revision 2 as of 2012-08-23 12:07:44
Size: 8216
Comment: Updated image captions and removed references to images in body text
Deletions are marked like this. Additions are marked like this.
Line 39: Line 39:
repository → choose '''Team → Share Project...''' (Image 1).

{{attachment:shareproject.png|Image 1}}

This brings up a dialog (Image 2) asking which repository plugin you
repository → choose '''Team → Share Project...''':

{{attachment:shareproject.png|Share Project}}

This brings up a dialog asking which repository plugin you
Line 45: Line 45:
will choose Mercurial.

{{attachment:shareproject2.png|Image 2}}
will choose Mercurial:

{{attachment:shareproject2.png|Repository Type}}
Line 50: Line 50:
root of your repository (Image 3), or you can choose to initialize a root of your repository, or you can choose to initialize a
Line 53: Line 53:
So lets just use the project folder as our repository.

{{attachment:shareproject3.png|Image 3}}
So lets just use the project folder as our repository:

{{attachment:shareproject3.png|Mercurial Repository Location Setup}}
Line 59: Line 59:
navigator (Image 4), and a lot of version control commands are navigator, and a lot of version control commands are
Line 63: Line 63:
{{attachment:shareproject4.png|Image 4}} {{attachment:shareproject4.png|Project Explorer}}
Line 69: Line 69:
Existing Mercurial Repository wizard (Image 5).

{{attachment:hgclone.jpg|Image 5}}
Existing Mercurial Repository wizard.

{{attachment:hgclone.jpg|New Project}}
Line 74: Line 74:
options, like username and password if required (Image 6).


{{attachment:image6.png|Image 6}}

When the clone has been made, a new dialog is shown (Image 7). This
options, like username and password if required.

{{attachment:image6.png|Clone Repository Wizard}}

When the clone has been made, a new dialog is shown. This
Line 82: Line 81:
the tabs in Image 7.

{{attachment:image7.png|Image 7}}
the tabs.

{{attachment:image7.png|Select Working Directory Revision}}
Line 87: Line 86:
should be imported into Eclipse workspace (Image 8).

{{attachment:image8.png|Image 8}}
should be imported into Eclipse workspace.

{{attachment:image8.png|Import Projects}}
Line 92: Line 91:
is shown in the Project Explorer (Image 9).

{{attachment:image9.png|Image 9}}
is shown in the Project Explorer.
Line 100: Line 97:
a dialog (Image 10), where you have to enter a commit message and can a dialog, where you have to enter a commit message and can
Line 103: Line 100:
{{attachment:commit.png|Image 10}} {{attachment:commit.png|Commit}}
Line 111: Line 108:
can be entered and other options can be set (Image 11).

{{attachment:push1.png|Image 11}}
can be entered and other options can be set.

{{attachment:push1.png|Push Changesets}}
Line 116: Line 113:
is shown (Image 12). Here it is possible to see all the changesets is shown. Here it is possible to see all the changesets
Line 122: Line 119:
{{attachment:push2.png|Image 12}} {{attachment:push2.png|Outgoing Changesets}}
Line 125: Line 122:
done in a similar way (Image 13 and Image 14), but of course starting done in a similar way, but of course starting
Line 131: Line 128:
{{attachment:pull1.png|Image 13}} {{attachment:pull1.png|Pull Changesets}}
Line 137: Line 134:
{{attachment:pull2.png|Image 14}} {{attachment:pull2.png|Incoming Changesets}}
Line 145: Line 142:
{{attachment:switchto1.png|Image 15}} {{attachment:switchto1.png|Update}}
Line 152: Line 149:
{{attachment:switchto.png|Image 16}} {{attachment:switchto.png|Switch To}}
Line 161: Line 158:
information on this changeset is shown (Image 17). If '''Show information on this changeset is shown. If '''Show
Line 169: Line 166:
{{attachment:showhistory1.png|Image 17}} {{attachment:showhistory1.png|Show History}}
Line 173: Line 170:
file (Image 18).

{{attachment:showhistory21.png|Image 18}}
file.

{{attachment:showhistory21.png|Right Click on Changeset}}
Line 179: Line 176:
one of them and choose compare with each other (Image 19).

{{attachment:showhistory31.png|Image 19}}
one of them and choose compare with each other.

{{attachment:showhistory31.png|Right Click on File}}
Line 188: Line 185:
revision to merge with by default (Image 20).

{{attachment:merge12.png|Image 20}}
revision to merge with by default.

{{attachment:merge12.png|Merge}}
Line 193: Line 190:
where these conflicts are (Image 21).

{{attachment:merge2.png|Image 21}}
where these conflicts are.

{{attachment:merge2.png|Conflict View}}
Line 198: Line 195:
file, or the merge editor (Image 22), which shows the difference between file, or the merge editor, which shows the difference between
Line 203: Line 200:
{{attachment:merge31.png|Image 22}} {{attachment:merge31.png|Merge Editor}}

MercurialEclipse

MercurialEclipse is a plugin for Eclipse that provides Mercurial integration.

Homepage: https://bitbucket.org/mercurialeclipse/main/

Below we'll go through the very basics of using Mercurial from within Eclipse, via the MercurialEclipse plugin.

1. Getting the Plugin

The MercurialEclipse plugin can be installed either from Eclipse Marketplace, under Help → Eclipse MarketPlace... or from an Eclipse Update Site for MercurialEclipse. See more on the MercurialEclipse homepage.

When installing from Eclipse Marketplace it is not possible to install Mercurial binaries, so there you have to install Mercurial yourself. If you choose the update site you can choose to have the Windows binaries installed with MercurialEclipse. However, this is an older version of Mercurial compared to what you would get if you installed, say, TortoiseHg. What I usually do is install TortoiseHg with the bundled Mercurial, and make MercurialEclipse use that installation. Since Mercurial is very stable, it is not a problem to change to a newer version than MercurialEclipse is made to work with.

2. Creating a Repository

The recommended practice in Mercurial is one repository per project, and this is also what will be assumed in this tutorial.

Although Mercurial is a distributed version control system then people often use a central repository as the canonical repository, but you can of course also create your repository locally. This is done in the following way: Right click on the project you want to make into a repository → choose Team → Share Project...:

Share Project

This brings up a dialog asking which repository plugin you want to use to share your project. Since this is about Mercurial, we will choose Mercurial:

Repository Type

Now you have the possibility to use the current project folder as the root of your repository, or you can choose to initialize a repository somewhere else. There will not be a connection between the project and the repository, if you choose the somewhere else option. So lets just use the project folder as our repository:

Mercurial Repository Location Setup

Now we have initialized the root folder of our project as a repository. So now we can see the status of the repository in the navigator, and a lot of version control commands are available under the Team context menu, for the project and for the file. The essential ones of these will be described below.

Project Explorer

3. Cloning

If the repository is already created, you can clone a repository by choosing File → New → Project... and then choose the Clone Existing Mercurial Repository wizard.

New Project

The wizard then lets you then specify the URL to clone from and other options, like username and password if required.

Clone Repository Wizard

When the clone has been made, a new dialog is shown. This dialog lets you choose which revision the working copy should be updated to. You can both type a revision or select one, by browsing the tabs.

Select Working Directory Revision

The final dialog lets you decide whether what now has been cloned should be imported into Eclipse workspace.

Import Projects

As we saw when creating a new repository, the working directory status is shown in the Project Explorer.

4. Committing

To make a commit use Team → Commit... for the context menu for a project or a file if you want to commit a single file. This brings up a dialog, where you have to enter a commit message and can specify some other commit options, e.g. leaving out some files.

Commit

5. Pushing and Pulling

Since Mercurial is a distributed version control system, commits are only local. To push these to another repository, e.g. the canonical one, one should use Team → Push... the team menu for the project context menu. This also brings up a dialog, where the push destination can be entered and other options can be set.

Push Changesets

After you have set the options for pushing, then a new dialog window is shown. Here it is possible to see all the changesets that's going to be pushed, and by clicking on a changeset, it can be seen what it consists of. So here you can check if you really want to push the changes your are about to. When you are sure, then push the changes by pressing the Finish button.

Outgoing Changesets

If we want to receive changes from another repository then this is done in a similar way, but of course starting with the Team → Pull... menu item instead. One thing to notice is that default behavior of pull in MercurialEclipse is to update after pull, which is different from the default behavior when pulling from the command line.

Pull Changesets

Just as you get to see the outgoing changesets when pulling, you get to see the incoming ones before pulling, so you can check whether you really want to pull in those changes.

Incoming Changesets

6. Update

In the Team menu for the project there is an Update menu item. This will update the working directory to the tip of the current named branch.

Update

If the working directory should be updated to a different revision, then the Team → Switch To... menu item should be chosen, which brings up a dialog to select the place in history to update the working directory to.

Switch To

7. Show History

A reason to have a version control system is to be able to see the earlier states of the project. The Team menu includes a Show History both for the project, and for the files. Both will bring up a History view showing a revision graph, with information on the changesets, and if a changeset is selected, then more specific information on this changeset is shown. If Show History is done on a file, only changesets in which the file was changed are shown.

There can also be updated to a revision from the History View, by right clicking on a changeset and select Switch Repository to Selected Changeset.

Show History

When a changeset is selected, files edited in that changeset is shown, and can be opened or compared with current or previous version of that file.

Right Click on Changeset

If the History View shows history for a specific file, then two revision can be compared by selecting two revisions, right clicking on one of them and choose compare with each other.

Right Click on File

8. Merging

To perform a merge choose Team → Merge... from the team menu from the project context menu. Choose the revision you want to merge with. If there is only one other head this is suggested as the revision to merge with by default.

Merge

If the merging results in conflicts the Mercurial Merge View shows where these conflicts are.

Conflict View

From this view you can bring up either the default editor for the file, or the merge editor, which shows the difference between the two editions of the file. It is also from this view you can finish or abort a merge. A merge cannot be finished until all conflicts has been marked as resolved.

Merge Editor

9. Much More...

Almost everything that can be done via the command line can also be done by MercurialEclipse, therefore a lot more things can be done from inside Eclipse, but what was described here was the very basic commands for interaction with a Mercurial repository.

MercurialEclipse (last edited 2020-09-02 09:43:52 by MarcGuenther)