Working with SVN
The purpose of this tutorial
is to teach you how to work with the SVN source control system. You will
learn how to configure your SVN repository, upload projects and files
to it, check out (import) projects and files from it and commit changes
which you have made to files.
Contents:
Purpose
SVN, or Subversion, is a source control
system intended to allow a team or group to work on the same files and
projects simultaneously, and to be able to revert file and project states
back to previous versions.
Adding
an SVN Repository
Before you can add projects to or export projects from SVN, you must
define your SVN repository settings.
Note:
To access a repository, make sure that an SVN server
is already configured.
|
|

|
To add a new SVN repository:
Open the SVN perspective
by going to Window | Open
Perspective | Other | SVN Repository Exploring.
In the SVN Repositories
view, click the Add SVN Repository button
on the view's toolbar -or- right-click within the SVN view
and select New | Repository
Location.
The Add SVN Repository dialog will open.
Enter the information
required to identify and connect to the repository location:
Click Finish.
Your SVN repository will now be added to the SVN Repository
view.
|
|
Back to Top
Sharing Projects
Through SVN, projects can be shared and worked on by numerous team members.
|
|

|
The following steps demonstrate
how to upload a project to your SVN repository location:
Create a new PHP
project called "MySVN Project".
Within the project,
create a PHP file called "SVNFile1" with the following
code:
<?php
//This is a new file
?>
In PHP Explorer
View, right-click your project and select Team
| Share Project.
A Share Project dialog will open.
From the repository
list, select SVN and click Next.
Select 'Use existing
repository location', and select your repository from the
list.
Click Finish.
Depending on your
authentication settings, a dialog might appear asking you
to provide authentication information.
Re-enter your password and click Next.
(Mark the Save Password checkbox to ensure that this screen
does not reappear.)
A Commit dialog
will open. Enter the comment "I am uploading files to
SVN." and click OK.
In PHP Explorer
View, your project will now have a repository icon ,
indicating that it is in SVN.
Once you have
committed your files, other team members will be able to access
and change the files.
|
|
The instructions below explain how users can check out (import) projects
from SVN, edit them and upload their changes.
Back to Top
Checking
Out Projects from SVN
Once projects are placed on the SVN repository, they can be checked
out (imported) by anyone with access to that repository.
|
|

|
The following steps demonstrate
how to check out (import) projects from SVN into your workspace:
Delete the 'MySVN'
project from from your workspace in order to simulate being
a new user who has not previously had access to this file.
Note: Deleting the project from your workspace will not delete
it from SVN.
Go to File Menu
and select Import | Projects
from SVN.
Click Next.
Select your repository.
Click Next.
A 'Select Resource'
dialog will appear. Expand the nodes until you see your project
(by default, this will have been placed under 'Trunk').
Select your project
and click Finish.
A 'Check Out As' dialog will appear.
Leave the 'Check
out as a project with the name specified' option marked and
click Finish.
|
The
project will now be imported into your workspace.
Note that the project will have an SVN repository icon
in your PHP explorer view. |
Now that you have imported a project from SVN into your workspace, you
can add files, edit existing files and commit your changes to the SVN
repository. (See below).
Back to Top
Adding Files to Existing
Projects
You can add files to existing projects in the SVN repository and commit
them so that other users can access them.
|
|

|
The following steps demonstrate
how to add and commit a file into an existing project:
In your SVNProject,
create a new PHP file, called "SVNFile2" with the
following code:
<?php
//Another new file
?>
Save the file.
In PHP Explorer
View, select the file, right-click and select Team
| Commit.
A Commit dialog
will open.
Enter a comment "Another new file added." and click
OK.
|
The
file will be committed to SVN and will be accessible by other
users. |
Back to Top
Making
Changes, Comparing Changes, and Committing Changes
Once files are stored on SVN, you and all other team members can make
changes to the files and commit them. Before committing changes you have
made to a file, you can compare the file stored locally in your workspace
to the file stored on the SVN repository.
Making and Comparing Changes
|
|

|
The following procedure demonstrates
how to make changes to files and comparing local files to files
in the repository:
Open SVNFile1
in your SVNProject.
After the text
"This is a new file.", add "I have made a change".
Save the file.
In PHP Explorer view, the file and project will have a ">"
suffix, indicating that a change has been made which has not
yet been committed.
So far, the changes
have only been saved in your workspace. In order to compare
the local file to which you have made changes with the one
sitting in the SVN repository, right-click the file in the
PHP Explorer view and select Team
| Synchronize with Repository.
Click Yes
when asked whether to open the Team Synchronizing perspective.
(Check the 'Remember my decision' box to prevent this prompt
from appearing in the future.)
|
A
Text Compare dialog will open showing the local file you have
just made changes to (in the left-hand window) as compared to
the file in the repository (in the right-hand window).
The change you have made will be highlighted.

In addition, the Synchronize view will have opened in the left
hand-side, displaying the file to which you have made changes.
The file will have a grey arrow icon indicating
that changes have been made which need to be synchronized with
the repository. |
Committing Changes
Once you have edited your file and compared it to the one in the repository
to ensure that the changes are correct, you can commit your changes.
|
|

|
To commit your changes to the repository:
From the Synchronize
view, click the 'Commit All Outgoing Changes' button.
-Or- In PHP Explorer View, right-click your file and select
Team |
Commit.
A
Commit dialog will open.
Enter the comment "I have made changes to SVNFile."
and click Finish.
|
Your
changes will now be committed to SVN and all users will be able
to access the file. |
Back to Top
Replacing Files
with Older Versions
Using SVN's version control system, you can revert back to older versions
of files if incorrect changes have since been made.
|
|

|
This procedure demonstrates how
to replace your file with an older version:
In the PHP Explorer
view, select your SVNFile1 and from the right-click menu select
Replace with | Revision.
A Replace with Revision dialog will open.
Select Revision
and click Select.
A Select Revision dialog will open, listing the various times
the file has been committed (revisions).
As committed changes have been made twice (once during the
original upload and once when you edited the file), 2 revisions
should be listed with their relevant comments.

Scroll between
the two revisions.
To return the file to it's previous state, select the second
revision in the list (containing the comment "I am uploading
files to SVN.") This is the original state the file was
in when it was first uploaded.
Click OK.
You will be returned to the Replace with Revision dialog, which
will now have a revision number in the Revision box.
Click OK.
You will be prompted to confirm that you would like to replace
the revision.
Click Yes.
|
Your
project will be reverted to the old one and the line "I have
made a change" will be removed from SVNFile1. |
Back to Top
Deleting Files from
SVN
You can delete a file from the SVN repository so that the file will
no longer be available to any users.
|
|

|
This procedure demonstrates how
to delete a file from SVN:
Open the SVN Repositories
view.
Expand the nodes
to find your project.
Right-click the
file you would like to delete and select Delete.
A "Commit Deletion" dialog will open.
Enter a comment
if required.
Click OK.
|
The
file/project will be deleted from your SVN repository. |
Note:
This action will delete the file from the SVN repository
and not just from your workspace. This file will no longer be accessible
by any users.
See the Subversive
User Guide for more information on the SVN plugin.
Back to Top