Frage

We are a team of two developers developing PHP/MySQL applications. We've been using Netbeans/TortoiseHG for some time now, but as our projects do not cross, and development is fairly simple and straight forward, we've been using Mercurial mainly to have a central repository where both of us can find the latest version of whatever the other one is working on.

So far, the development path follow very simple steps:

  1. Create project in Netbeans
  2. Create repository in Tortoise
  3. Have a clone of this Tortoise repository in a shared space
  4. As development progresses, commit, push (in case one of us had to make changes to the other's projects in his absence), and pull.

As you can see, very simple and limited, but sufficient for our needs.

But now I'm working on a project that will require real version-control. In my case, this means that I will need to keep two separate and independent development paths, one for production and one for development:

  • one version (let's call 1.0) would reflect what is in production and will be updated as needed. Development here would be based on errors found in production and requests from users; (these changes would probably have to propagate to "the other version";
  • the other version (let's say 2.0), would be the place where I would work on new features that will not be in production for at least a few months..

My question is, how should I set up this project, from directory structure to NetBeans and TortoiseHG? What are the best practices?

By the way, I'm using NetBeans IDE 7.3 and TortoiseHG 2.7.1 with Mercurial-2.5.2

To give you a sense of where I am, I've played a little bit with branching in TortoiseHG but the results I got were not what I expected (I didn't get the two independent sets of files I hoped, as to work on them independently). I don't know if I was doing it wrong or if branching is not what I need.

So, having failed with branching and not knowing what to do, I thought about creating multiple folders/directories inside the same Netbeans project, one for each version and name each folder after its version (version1.0, version2.0, version3.0...). Then I would place the whole file structure of the project inside each of these folders and keep a manual control of the updates, i.e., after any change, I would manually copy the files from one "folder version" to another, as needed. But this looks so wrong in so many levels.

Based on what I wrote, can you tell me how to correctly approach this? What are the best practices? Or could you point me in the right direction where I can find tutorials explaining how to get there?

Thanks, S.

War es hilfreich?

Lösung 2

Thank you CosLu,

You placed me in the right path and now I understand how this works...

The branching is the way to go, but it does not create a second project in your NetBeans Environment. Instead, you have as many branches in TortoiseHG/Mercurial as you need, and only one of them at a time will show in your NetBeans environment.

In few steps, this is how I understand it works.

  1. You create your project in NetBeans and TortoiseHG (create might not be the best term)
  2. You work on your project and commit your changes.
  3. When you get to a point that you want to start working on a second path in the project, do this:
  4. Commit all your changes so far
  5. Create a new branch: In NetBeans, you can right-click on the project, followed by Mercurial -> Branch -> Create Branch (give it a name)
  6. Work on changes for this new branch
  7. Commit your changes. If you go now to TortoiseHG, you will see a new branch showing.
  8. If you want a 3rd branch, repeat steps 3 to 7.

To work on a different path (branch) from the one that is currently active, simply go to TortoiseHG, right-click at the head of the branch you want to work, and select "Update". Click OK in the confirmation dialog box and you will be ready to go. In your NetBeans environment, your project will reflect that branch.

It's very important that you pay attention on which branch is active at that moment, so you do not make changes to the wrong branch.

The only part of this puzzle that I don't know yet is how do I commit selective changes from one branch to another. For example, if I make changes to my production system and want it reflected on my development one, without merging them, how do I do it? But this is beyond the scope of this question...

Andere Tipps

This is how I work in a similar situation with Netbeans and Subversion. Probably is not exactly the same but my experience might help.

Branches are indeed supposed to serve your purpose so I don't understand what do you mean with the fact that you didn't get different sets of files.

Even if the project has multiple versions i create only 1 project in nb with 1 local copy. (no multiple folders or project for each version).

Let's say that you have started this project and that you already have it in the trunk of your repository. Now you should want to create a new branch to contain the changes that you would like to upload in the future.

Just right click on a folder in the project view in NB (maybe in your case the root folder) and select:

subversion > copy > copy to

There you should be able to locate the branch folder in your shared repository and select it to make a brand new copy of your project.

From now on it's pretty easy. Everytime you have to switch from your main project to your future updates you can select which version of the file you have to work on:

subversion > copy > switch to copy

Here you can select to update your local file to the trunk or another branch.

subversion > copy > merge changes

This option in the end will allow you to merge the different branches and the trunk in a single file.

Very useful is also the possibility to show labels next to the files showing on which version of the file are you working on:

svn version next to file

Here it's clearly showed that i'm not working on the trunk version of the file but on a branch called test.

how bout creating a 3rd branch from the 2nd branch. And merge the 3rd branch with the 1st. the 2nd branch remains unmerged.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top