From ScorecWiki

(Redirected from Subversion(SVN))
Jump to: navigation, search

We are moving from CVS to Subversion for source control.



svn checkout
svn log

Short tutorial on SVN

0. First, set the text editor SVN will open when a commit message is needed. Open the ~/.subversion/config file and changing the line:

 # editor-cmd = editor (vi, emacs, notepad, etc.)


 editor-cmd = gedit

if you like the gedit graphical text editor or

 editor-cmd = vim

if you prefer vim.

1. Download the CMake IPComMan branch.

 svn checkout ipcomman

2. Add a NEWS file at the top level.

 cd ipcomman
 touch NEWS
 svn add NEWS

3. Check the state of your files with respect to the version you most recently checked out or updated to. The following command should include the line 'A NEWS'. This indicates that NEWS was added, but not commited.

 svn status

4. Commit the changes to the repository. Once you enter the following command you will be asked to write a descriptive, but not necessarily long, commit message that will tell other developers why the new file is needed.

 svn commit NEWS

5. Check the state of your files. NEWS should not be listed. This indicates that NEWS has not been modified since last checkout or update.

 svn status

6. Change the NEWS file in your favorite editor and save the change(s).

7. Check the state of your files. You should see 'M NEWS'. This indicates that NEWS has been modified since last checkout or update.

8. Commit the changes to the repository. Once you enter the following command you will be asked to write a descriptive, but not necessarily long, commit message that will tell other developers what changes were made and why. For this commit you can enter 'testing svn commit'.

 svn commit NEWS

Learning SVN

  • Revision numbers are for the entire tree.
  • Coppies in SVN are cheep. As such, almost everything is based on copying:
    • Making a branch is just making a copy of a subtree.
    • Making a "tagged" release is just making a copy of a subtree.
  • Merging merges a range of the source tree onto the destination. (Will say more.)
  • Copying a file with cp and then adding it with svn add is a bad idea because SVN can't keep track of its liniage.
  • Set your text editor by changing the enviroment variable EDITOR
    • export EDITOR=vim


Conceptually, a merge takes a diff of an entire subtree of the repository and applies it to another subtree of the repository. So if you made a branch, /branches/MyBranch at revision 10 of the repository and now are at revision 20 and want to merge that branch back into trunk, you want svn to apply all of the changes you made in that time to trunk. (You can always just say HEAD rather than a number if you want the latest revision; you can look at the end of svn log to find when a branch was forked.) With the entire repository checked out, to do this you would cd to the trunk directory and do the following:

OurProject/trunk$ svn merge -r 10:20 ../branches/MyBranch .

Then you would do

OurProject/trunk$ svn status

to see if there were any conflicts. It might say


saying that has conflicts. You can then manually edit that file to resolve it. When you have fixed you run

OurProject/trunk$ svn resolved

to let svn know it is resolved, then you can check it in.

For your reference, when you called svn merge, it created extra files for each conflict:

  • is the local copy of just before svn merge.
  • is an attempted merge. Conflicts are indicated in the file.
  • ???
  • is version of the file in ../branches/MyBranch/.

Create a Branch

To create a branch which is a copy of a current trunk do the following:

svn cp<project source path><project source path>/branches/<branch name>.

Create Local SVN Repository

Following this tutorial a local sub-versioning repository can be created within your SCOREC home directory.

This is useful when composing and maintaining a LaTex document or program that is suitable for placement on SCOREC Gforge SVN.

First create a SVN repository. Note that your projects controlled by this svn can be placed in any linux filesystem; i.e. you linux laptop, another location in your SCOREC user directory etc... .

  svnadmin create --fs-type fsfs ~/svn

To create a new empty project:

  svn mkdir file:///users/<user_name>/svn/MyEmptyProject

To 'checkout' this project from SCOREC:

  svn co file:///users/<user_name>/svn/MyEmptyProject <destination_directory_for_project>

To 'checkout' this project remotely:

  svn co svn+ssh://<user_name><user_name>/svn/MyEmptyProject <destination_directory_for_project>

To create a project from an existing directory use the following command. Then use 'checkout' to make a local svn controlled directory.

  svn import /path/to/project/ file:///users/<user_name>/svn/<project_name>/trunk

Using SVN Externals

To create a reference to the M4 macro repository from the current directory enter the following command:

  svn propedit svn:externals .

Then add the following line within the text editor:


Access from the CCNI

To checkout a repository enter the following command from one of the Landing Pads:

 svn co<Project Name>/<Repository path> --username <SCOREC Username>


Internal links

External links

Personal tools