workflow: create and init multi-project repositories with HgEclipse (Mercurial)

This workflow is part of my DVCS blog series. If you don’t understand some steps, please read the first parts of the series.

The goal: Workspace with n Projects in same Mercurial Repository

It’s usual that you have to create a new repository containing some projects from inside your eclipse workspace. Here’s the workflow how to do this using HgEclipse. If you already cloned a multi-project repository into your workspae and only want to add a new project, then start with step 2 “Add another project to the Repository“.


(Eclipse Workspace “n-projects-workspace” contains a Mercurial Repository “n-projects-ws-repo” where two projects (“org.ekkescorner.one” and “org.ekkescorner.two“) are under version control.)
The short story:

  1. Create and init the Repository
  2. Add the first project to the Repository
    1. Create the first project (at non-default location)
    2. Share the first project (connect to  Repository at parent directory)
    3. Add and Commit ressources to Repository
  3. Add another project to the Repository
    1. Create the second project(at non-default location)
    2. Add and Commit ressources to Repository
  4. You’re done: 2 projects in your workspace share same Repository

the long story:

1. Create and init the Repository

Open the View “Mercurial Repositories” and click on “Create Repository” :

Because we want to create a repository in our workspace, we need a Local URL – hitting “Local…” you can browse to the location and create / open a directory there. The Repository location is:

<workspace>/<repository>

Please don’t forget to watch if the checkbox “Init Mercurial repository” is checked ! Click “Finish” and the Repository is visible in the View:

2. Add the first project to the Repository

2.1 Create the first project (at non-default location)

Now let’s add the first new project. Please uncheckUse default location” and enter your new location:

<workspace>/<repository>/<project>

Hint: Doubleclick on the Repository in “Mercurial Repositories” View you can copy the path to the repository and paste into the “New Project” Location.

This will create your project one level deeper as usual, so it’s directly where we created the repository before. Now the new project is immediately visible in your “Mercurials Repositories” View:

2.2 Share the first project (connect to Repository at parent directory)

Option-click on your project from Package Explorer or “Mercurial Repositories” View: “Team -> Share Project…

Share the project as a Mercurial project:

Then it’s easy to connect the project to your Repository:

HgEclipse detects the repository from the parent directory, so you can use the defaults and only click “Finish“. Immediately the project is decorated as “under version control”:

Ressources not yet in your repository are marked with a question mark, the project itself is marked as “new”.

Hint: you can look at the project from Package Explorer or “Mercurial Repositories” where the latter perhaps displays more files if you’re using default filter at package explorer. I’m always using the “Mercurial Repositories” View. Also the Team -> Options Menu is shorter from there and easier to select.

2.3 Add and commit ressources to Repository

As next we have to add and commit the missing ressources to the repository. HgEclipse allows us to combine the “Add” and “Commit” steps. “Team -> Commit…” shows this dialog:

Please ebnter a message. It’s easy to commit all new (not added yet) files: if “Show untracked files” is checked, all are visible, if “Select all” is checked, all are added. Hit “OK” and your first project is under Version Control:

The project itself changed decoration from “new” into “default(tip)“.

3. Add another project to the Repository

3.1 Create the second project(at non-default location)

Repeat step 2.1

Great: you have to do nothing to share the project – this was immediately done by HgEclipse :)

3.2 Add and commit ressources to Repository

repeat step from 2.3

4. You’re done: 2 projects in your workspace share same Repository

Using HgEclipse you can easy control the content of your repository from “Mercurial Repositories” View:

Double-clicking on a Repository shows the Properties with Location, option-click gives you:

You can import projects into workspace, if not all from repository are already there, clone the repository, refresh or remove.

double-clicking on a project displays the Project Properties for Mercurial:

To solve the same task using Git /EGit: here’s the workflow.

This workflow is part of my DVCS blog series – an overview of all workflows can be found here.

2 responses

  1. Ekke,

    This is an excellent and timely set of posts you have created. A note; in section 2.2 you guide us through sharing the project. I didn’t have to do that, adding the project underneath the newly created repository automatically shared it for me (it was labeled with [new]), as adding subsequent projects does in your tutorial.

    To comment on the plugin itself (and I could be using it wrong I’m sure) it seems a little counter-intuitive that we still work on a project-level with regards to the repository, even though a commit on one project essentially brings every project in that repo up to the same/new revision level.

    Thanks again, am enjoying the tutorials.

    Paul

    • Paul,
      thanks for the kudos…
      I was also wondering why I had to add the first project but not the following ones. perhaps something changed (I’m using beta snapshots)… or OSX… I’ll watch this – thanks for info.
      perhaps the other issue (committing one project really commits from all projects) you should ask at HgEclipse Forum ?

      http://www.javaforge.com/proj/forum/browseForum.do?forum_id=10094

      …then we can discuss there
      ekke

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s