Collaborative Work with SVN and Git

0
118
11 min read

(For more resources related to this topic, see here.)

Working with SVN

At first we will take a look at the SVN perspective.The SVN perspective provides a group of views that help us to work with a Subversion server. You can open this perspective by using the Perspective menu in the top-right of the Aptana Studio window.

The important and most frequently used views related to SVN, which we will take a look at, are the SVN Repositories view, the Team | History view, and the SVN | Console view. These views are categorized as the views selection into the SVN and Team folder, as shown in the following screenshot:

 

 

The SVN Repositories view allows you to add new repositories and manage all available repositories. Additionally, you have the option to create new tags or branches of the Repository. These views belong to the SVN views, as shown in the following screenshot:

The History view allows you to get an overview about the project and revisions history. This view is used by SVN and Git projects; for this reason the view is stored in the Team views group. The History view can be opened by the menu under Window | Show View | History. Here you can see all the revisions with their comments and data creation. Furthermore, you can get a view into all revisions of a file and you also have, the ability to compare all revisions. The following screenshot shows the History view:

Within the SVN Console view, you will find the output from all the SVN actions that are executed by Aptana Studio. Therefore, if you have an SVN conflict or something else, you can take a look at this Console view’s output and you might locate the problem a bit faster. The SVN Console view was automatically integrated in the Aptana Studio Console, while the SVN plugin was installed. So if you need the SVN Console view, just open the general Console view from Window | Show view | Console. If the Console view is open, just use the View menu to select the Console type, which in this case is the SVN Console entry.

The following screenshot shows the Console view and how you can select SVN Console:

However, before we can start work with SVN, we have to add the related SVN Repository.

Time for action – adding an SVN Repository

  1. Open the SVN perspective by using the Perspective menu in the top-right corner of the Aptana Studio window.

  2. Now, you should see the SVN Repositories view on the left-hand side of the Aptana Studio window. If it does not open automatically, open it by selecting the view from the navigation Window | Show view | SVN Repositories.

  3. In order to add a new SVN Repository, click on the small SVN icon with the plus sign at the top of the SVN Repositories view.

  4. You will now have to enter the address of the Subversion server in the pop up that appears, for example, svn://219.199.99.99/svn_codeSnippets.

  5. After you have clicked on the Finish button, Aptana Studio tries to reach the Subversion server in order to complete the process of adding a new Repository.

  6. If the Subversion server was reached and the SVN Repository is password protected, you will have to enter the access data for reading the SVN data.

  7. If you don’t have the required access data available currently, you can abort the process and Aptana Studio will ask you whether you want to keep the location. If you click on NO, the newly added SVN Repository will be deleted, but if you click on YES, the location will remain. This allows you to retrieve the required access data later, enter them, and begin to work with the SVN Repository.

  8. Regardless of whether you keep the location or enter the required access data, the new SVN Repository will be listed in the SVN Repository view.

What just happened?

We have added a new SVN Repository into Aptana Studio. The new Repository is now listed in our SVN Repositories view and we can check this out from there, or create new tags or branches.

Checking out an SVN Repository

After we have seen how to add a new SVN Repository to Aptana Studio, we also want to know how we can check this Repository in order to work with the contained source code.

You can do this, like many other things are done in Aptana Studio, in different ways. We will take a look at how we can do this directly from the SVN Repositories view, because every time we add a new Repository to Aptana Studio, we will also want to check it and use it as a project.

Time for action – checking out an SVN Repository

  1. Open the SVN Repositories view.

  2. Expand the SVN Repository that you wish to check out. We do this because we want to check out the trunk directory from the Repository, not the tags and branches directory.

  3. Now, right-click on the trunk directory and select the Check Out… entry.

  4. Aptana Studio will now read the properties of the SVN Repository directly from the Subversion server. When all the required properties are received, the following window will appear on your screen:

  5. First of all, we select the Check out as a project in the workspace option and enter the name of the new SVN project.

  6. After this, we select the revision that we want to check out. This is usually the head revision. This means that you want to check out the last committed one—called the head revision. But you can check out any revision number you want from the past. If this is so, just deselect the Check out HEAD revision checkbox and enter the number of the revision that you want to check out.

  7. In the last section, we select the Fully recursive option within the Depth drop-down list and uncheck the Ignore externals checkbox, but select the Allow unversioned obstructions checkbox.

  8. After you have selected these settings, click on the Next button.

  9. Finally, you can select the location where the project should be created. Normally, this is the current workspace, but sometimes the location is different from the workspace. Maybe you have a web server installed and want to place the source code directly into the web root, in order to run the web application directly on your local machine.

  10. Finally, whether you select a different location for the project or not, you have to click on the Finish button to finalize the “Check out” into a new project.

What just happened?

We have checked out an SVN Repository from the SVN Repositories view. In addition to that, we have seen how we can also check out the Repository source code into another location other than the workspace. Finally, you should now have a ready SVN project where you can start working.

File states

If you’re now changing some lines within a source code file, the Project Explorer view and the App Explorer view change the files’ icon, so that you see a small white star on the black background. This means the file has changed since the last commit/update.

There are some more small icons, which give you information about the related files and directories. Let’s take a closer look at the Label Decorations tab as shown in the following screenshot:

Now, we will discuss the symbols in the order shown in the previous screenshot:

  • The small rising arrow shows you that the file or directory is an external one.

  • The small yellow cylinder shows you that the file or directory is already under version control.

  • The red X shows you that this file or directory is marked for deletion. The next time you commit your changes, the file will be deleted.

  • The small blue cylinder shows you that the file or directory is switched. These are files or directories that belong to a different working copy other than their local parent directory.

  • The small blue plus symbol shows you that this already versioned file or directory needs to be added to the repository. These could be files or directories you may have renamed or moved to a different directory.

  • The small cornered square shows you that these files have a conflict with the repository.

  • The small white star on the black background shows you that these files or directories have been changed since the last commit.

  • If the file’s or directory’s icon has no small symbol, it means the file is ignored by the SVN Repository.

  • The small white hook on the black background shows you that this file or directory is locked.

  • The small red stop sign shows you that this file or directory is read-only.

  • The small yellow cylinder shows you that this file or directory is already under version control and unchanged since the last commit.

  • The small question mark shows you that this new file or directory isn’t currently under version control.

If you didn’t find your icons in this list, or your icons look different, no problem. Just navigate to Window | Preferences and select the Label Decorations entry under Team | SVN within the tree. Here you will find all of the icons which are used.

Committing an SVN Repository

If you have finished extending your web application with some new features, you can now commit these changes so that the changes are stored in the Repository, and other developers can also update their working copies and get the new features.

But how can you simply commit the changed files?

Unlike a Git Repository, SVN allows you to commit changes in a tree from the Repository. By using Git, you can only commit changes in the complete Repository at once. But for now, we want to commit our SVN Repository changes, therefore just follow the steps mentioned in the following Time for action – updating and committing an SVN Repository section.

Time for action – updating and committing an SVN Repository

  1. The first step, before performing a commit, is to perform an update on your working copy. Therefore, we will start by doing this, Aptana Studio reads all new revisions from the Subversion server and merges them with your local working copy. In order to do this update, right-click on your project root and select Team | Update to HEAD.

  2. When your working copy is up to date, navigate to the App Explorer view or the Project Explorer view and right-click on the files or directories that you want to commit, and then select the Commit… entry in the Team option.

  3. If you select a few directories or the whole project, the Commit window lists only those files within the selection that have changed since the last commit. So, you are able to select just the files and directories that you want to commit. Compose the selected files and directories as you need, and enter a comment in the top of the window.

    Why do you have to enter a comment while committing a change?

    Because, by committing the SVN Repository, it automatically saves the date, time, and your username; with this data the revision history stores information about who has changed which file at what time. In addition to that comes the commenting part. The comment should describe what kind of changes were made and what is their purpose.

  4. To finalize the commit, you just have to click on the OK button and the commit process will start.

  5. As described previously, you can see the output from all your SVN processes within the SVN Console view. In the following screenshot you can see the result of our commit process:

What just happened?

We have updated our working copy in order to commit our changes. Now the other developers can update their working copies too and can then work with your extensions.

It should be noted again that it’s recommended to perform an update before every commit. You can perform an update in a single file tree node. You don’t have to update your whole project every time, a single node can also be committed.

Updating an SVN Repository

Additionally, similar to the SVN check out, you have the option to update your working copy not only to the Head revision, but also to a special revision number. In order to do this, right-click on the project root within the Project Explorer view and select the Update to Head… option or the Update to Version… option under the Team tab. After selecting one of these entries, Aptana Studio determines all the new files and files to be updated, downloads them from the Repository, and merges them with your local working copy.

Now you should have all the source code from your current project. But, how can you identify which parts of a file are new or have been changed?

No problem! Aptana Studio allows you not only to compare two different local files, you can also compare files from different revisions in your Repository. Refer to the following Time for action section to understand how this works:

LEAVE A REPLY

Please enter your comment!
Please enter your name here