DEV Community

Abhishek Deshpande
Abhishek Deshpande

Posted on

Centralised Version Control Systems (CVCS) – Expanded Guide on SVN

Apache Subversion (SVN) is a Centralized Version Control System (CVCS) popular in the early 2000s and still used in many projects today, like WordPress.org. It stores the full version history on a central server, while developers work on local copies. Changes are saved back to the central repository to keep everyone’s work in sync.

While Git is now the industry standard, SVN is still important for many older and large projects because it’s simple and reliable.


Why Use SVN?

SVN is particularly valuable in situations where centralised control is preferred or where legacy systems depend on it. Here are some key features:

  1. Atomic Commits: Ensures all changes in a commit are applied together, reducing the risk of partial changes.
  2. Directory Versioning: Tracks changes not only to files but also to directory structures.
  3. Comprehensive History: Maintains a detailed log of changes, allowing for robust auditing.
  4. Access Control: Allows fine-grained control over who can read or write to specific parts of the repository.

Projects Still Using SVN

Several prominent projects continue to use SVN:

  • WordPress.org:

    The core WordPress software, plugins, and themes are still managed through SVN. Developers submit patches and updates via the SVN repository.

  • Apache Projects:

    Many Apache Software Foundation projects use SVN for code versioning.

  • Blender (prior to Git):

    The popular 3D modelling software used SVN before transitioning to Git.


Getting Started with SVN

Here’s how to start using SVN with practical commands:


Step 1: Install SVN

  brew install subversion
Enter fullscreen mode Exit fullscreen mode
  • Linux: Install using your package manager:
  sudo apt-get install subversion
Enter fullscreen mode Exit fullscreen mode

Step 2: Check Out a Repository

To start working with a project, you need to check out a copy of the repository to your local machine.

svn checkout https://example.com/svn/repository-name
Enter fullscreen mode Exit fullscreen mode

This will download the project files and create a working directory.


Step 3: Update Your Local Copy

Before making changes, ensure your local copy is up-to-date:

svn update
Enter fullscreen mode Exit fullscreen mode

This command synchronises your working directory with the latest changes on the server.


Step 4: Add New Files or Directories

If you create new files or directories, you must explicitly add them to SVN:

svn add filename
svn add directory-name
Enter fullscreen mode Exit fullscreen mode

Step 5: Commit Changes

Once you’ve made changes, you need to commit them to the repository:

svn commit -m "Commit message describing your changes"
Enter fullscreen mode Exit fullscreen mode

Step 6: View the History of Changes

To see a log of all changes made to the repository, use:

svn log
Enter fullscreen mode Exit fullscreen mode

Step 7: Revert Changes

If you make a mistake, you can revert your changes:

svn revert filename
Enter fullscreen mode Exit fullscreen mode

To revert all changes in your working directory:

svn revert -R .
Enter fullscreen mode Exit fullscreen mode

Step 8: Resolve Conflicts

When two people edit the same file, a conflict may occur. SVN marks the conflicting sections in your file. Resolve the conflict manually, then mark it as resolved:

svn resolve --accept mine-full filename
Enter fullscreen mode Exit fullscreen mode

Step 9: Delete Files or Directories

To delete a file or directory, use:

svn delete filename
Enter fullscreen mode Exit fullscreen mode

Commit the deletion:

svn commit -m "Removed unused file"
Enter fullscreen mode Exit fullscreen mode

Advanced SVN Commands

  1. Branching: Create a branch to work on a new feature:
   svn copy https://example.com/svn/repository/trunk https://example.com/svn/repository/branches/new-feature
Enter fullscreen mode Exit fullscreen mode
  1. Switching Branches: Switch your working directory to a different branch:
   svn switch https://example.com/svn/repository/branches/new-feature
Enter fullscreen mode Exit fullscreen mode
  1. Merging Branches: Merge changes from a branch back into the trunk:
   svn merge https://example.com/svn/repository/branches/new-feature
Enter fullscreen mode Exit fullscreen mode
  1. Exporting a Clean Copy: Export a copy of the project without version control metadata:
   svn export https://example.com/svn/repository/trunk
Enter fullscreen mode Exit fullscreen mode

Best Practices for SVN

  1. Commit Small Changes:

    Avoid bundling unrelated changes into a single commit. Smaller commits are easier to review and manage.

  2. Write Descriptive Commit Messages:

    Clearly explain what changes you’ve made and why.

  3. Update Frequently:

    Regularly update your working copy to avoid conflicts with changes made by others.

  4. Backup Repositories:

    Regularly back up the central repository to protect against server failure.

  5. Use Access Control:

    Restrict write access to critical parts of the repository to prevent accidental changes.


Why Learn SVN?

Even if you primarily use Git, understanding SVN is valuable because:

  1. Many legacy systems still rely on SVN.
  2. It provides insights into how centralised workflows function, which can help in understanding hybrid systems.
  3. Open-source projects like WordPress.org require contributors to use SVN.

SVN vs Git: Key Differences

Feature SVN Git
Architecture Centralised Distributed
History Storage Stored on the central server Stored on every developer's machine
Speed Slower for large repositories Faster due to local operations
Offline Access Limited Full access to history and operations
Adoption Legacy and niche projects Widely adopted across industries

Subversion (SVN) is a strong and dependable tool for projects that use centralized workflows or need directory versioning. If you’re working on an SVN project like WordPress.org or handling an older system, learning SVN is a useful skill for any developer.

Top comments (0)