Basic Subversion Repository Management

(This is a shared personal note, suggestions are welcome.)

Create a Subversion repository for a project, say The SVG Blog Icons:

  1. Create the repository on the hosting panel with a project name (e.g. Blog Icons) and project ID (e.g. blogicons).
  2. Import the files:
    bash$ cd src/
    bash$ ls
    blogicons
    bash$ export EDITOR=vi
    bash$ svn -m "First import" import blogicons http://svn.alkalay.net/blogicons/trunk
  3. Start over with a fresh copy:
    bash$ mv blogicons blogicons.old
    bash$ svn co http://svn.alkalay.net/blogicons/trunk blogicons
  4. Create a repository for pointers to official releases and register the official release the files imported represent:
    bash$ svn -m "Links of official releases" mkdir http://svn.alkalay.net/blogicons/tags
    bash$ svn -m "Official 20070518 version" cp http://svn.alkalay.net/blogicons/trunk http://svn.alkalay.net/blogicons/tags/20070518
  5. Check how it looks pointing the browser to http://svn.alkalay.net/blogicons/

Manage project files:

  • Add files
    bash$ cd blogicons
    bash$ svn add newfile.svg
    bash$ svn add newfiles.*
  • Remove files
    bash$ cd blogicons
    bash$ svn rm oldfile.svg
    bash$ svn rm oldfiles.*
  • To embed the file’s meta information in itself as a comment
    bash$ cd blogicons
    bash$ echo "<!-- $Id$ -->" >> file.xml
    bash$ echo "/* $Id$ */" >> file.c
    bash$ echo "// $Id$" >> file.cpp
    bash$ echo "# $Id$" >> file.sh
    bash$ echo "# $Id$" >> Makefile
    bash$ svn propset svn:keywords Id file.xml file.c file.cpp file.sh Makefile

    Every time changes and commits happen, the $Id$ tag will be replaced as this examples:

    <!-- $Id: file.xml 148 2007-07-28 21:30:43Z username $ -->
    /* $Id: file.c 148 2007-07-28 21:30:43Z username $ */
    // $Id: file.cpp 148 2007-07-28 21:30:43Z username $
    # $Id: file.sh 148 2007-07-28 21:30:43Z username $
    # $Id: Makefile 148 2007-07-28 21:30:43Z username $

    People use to put the $Id$ tag in the beginning of source files. The example show how to put in the end, but that’s because it is easy to represent it here in the documentation. You should put $Id$ tags in the beginning of the file.

  • Commit changes to repository
    bash$ cd blogicons
    bash$ svn -m "Changed color to red on icon A, moved the circle shape to left on icon C" commit

    Use descriptive comments favoring WHAT changed on files and not which files changed.


Posted

in

by