Subversion

Project Manipulation

Project Directory Structure

Organize your code to import into the following structure:

myproject/
myproject/branches/
myproject/tags/
myproject/trunk/
myproject/trunk/dir1/
myproject/trunk/file1
...
  • trunk - the main line of development, the leading edge, where developers usually commit their regular changes.
  • tags - a collection of snapshots of the trunk (or a branch) at a user-defined point in time, for instance release day.
  • branches - active variations of the project compared to the trunk (or even another branch). This is useful when working out a (big) change that needs to be coordinated in a team or when using a single working-copy for the work with the changeproject is not feasible.

Importing/ Creating a Project

Assuming the project directory is a subdirectory of the current directory, you would enter the following command:

svn import project file:///path/to/repository/newproj_name -m "First Import"

e.g.,

svn import Logic file:///home/courses/cs297/shared/svn/Logic -m "First Import"

Checking Out a Project

svn checkout file:///repository_name/project/trunk project

Adding Files or Directories

svn add file_or_dir_name

Deleting Files or Directories

svn delete file_or_dir_name

Committing Changes

 svn commit

Updating Files

svn update
Code Meaning
A Added
D Deleted
U Updated
C Conflict
G Merged

Tagging a Version

To give a version of the project a name, use svn copy

svn copy file:///path/to/repos/project/trunk \
         file:///path/to/repos/project/tags/release-1.0 \
    -m "Tagging the 1.0 release of the project."

Conflicts

Conflicts can be detected with the update command. When Subversion detects a conflict in a file, it places conflict markers into the file (to allow the user to find the places of the conflict) and creates the following three files in the directory:

  • filename.mine

The file without the conflict markers

  • filename.rOLDREV

The file as it was before I started to change it.

  • filename.rNEWREV

The HEAD revision of the file

Resolving conflicts Conflicts can be resolved by doing one of the following three things:

  • Merge the conflicting areas (conflict markers)
  • replace the file in question with one of the three files mentioned above
  • running svn resolved

Creating a Repository

svnadmin create /path/to/repos

The actual repository/directory should not have been created yet. This command will handle that for you.

Using ssh with svn

Use the svn+ssh:// URL schema to connect.

Example:

svn list svn+ssh://host.example.com/repos/project
harry@host.example.com's password:

Subclipse with Eclipse

Subclipse is a plugin for Eclipse that allows users to easily use Subversion with their code.

Installation

  • Help –> Eclipse Marketplace
  • Search for “Subclipse”
    • The first one that pops up should be something like Subclipse 1.10.##
  • Select it and click “Install”
  • Select All (Subclipse, SVNKit, …)
  • Go through the installation process, restart the workspace

After Installing

  • Under preferences
    • Under Team > SVN
      • SVN Interface: Client:
        • select SVNKit (Pure Java)
    • Under Team > Ignored Resources
      • Add patterns for .classpath, .project, .settings
      • These are files that are user-specific and should not be part of the shared repository.

Set Up Repository

  • Repository (works from home computer too):
    svn+ssh://username@atmos.cs.wlu.edu/svn/csrepos/repository_name

Team Menu

The Team menu is where you'll find the commands you need to work with the subversion repository.

Subclipse with Eclipse on Windows

  • In Eclipse, Windows –> Preferences
  • Team –> SVN
    • Interface: switch client to Pure Java

SVN GUI Clients

Of course, you may not want to use the command-line.

  • SmartSVN – free community version
  • PyCharm and other IDEs have plugins or built-in clients available
labs/subversion.txt · Last modified: 2016/10/14 16:12 by admin
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0