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:
- Create and init the Repository
- Add the first project to the Repository
- Create the first project (at non-default location)
- Share the first project (connect to Repository at parent directory)
- Add and Commit ressources to Repository
- Add another project to the Repository
- Create the second project(at non-default location)
- Add and Commit ressources to Repository
- 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:
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 uncheck “Use default location” and enter your new location:
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.