HOWTOlabs  
 Services     Software     Commentary     Design     Astral Musings   
Subversion
Sever Setup and Usage Tips
Elsewhere

Subversion is considered by many to be the successor to CVS for affordable electronic file version control.  Many Operating System distributions come with svn already installed.  For example Apple's OS X 10.5.X now includes svn 1.4.X, where previous releases required special installers.

Installing under Linux ...
# yum list \*subversion\*

  ...
  Available Packages
  subversion.i386         1.4.2-4.el5     base
  subversion-devel.i386   1.4.2-4.el5     base
  subversion-javahl.i386  1.4.2-4.el5     base
  subversion-perl.i386    1.4.2-4.el5     base
  subversion-ruby.i386    1.4.2-4.el5     base

# yum install subversion

  ...
  Installed: subversion.i386 0:1.4.2-4.el5
  Dependency Installed: apr.i386 0:1.2.7-11
  apr-util.i386 0:1.2.7-7.el5_3.1 neon.i386 0:0.25.5-10.el5
  perl-URI.noarch 0:1.35-3 postgresql-libs.i386 0:8.1.11-1.el5_1.1
  Complete!

# yum list \*inet\*

  ...
  Available Packages
  perl-IO-Socket-INET6.noarch                 2.51-2.fc6                      base
  xinetd.i386                                 2:2.3.14-10.el5                 base

# yum install xinetd 

  ...
  Installed: xinetd.i386 2:2.3.14-10.el5
  Complete! 
Create group (is this necessary?), create public/svn, create repository ...
$ ls -lhd /public/svn

  drwxrwsr-x 7 rickatech subvsn 4.0K Jul  5 20:40 /public/svn

$ svnadmin create /public/svn 
Import a simple project (using direct file mode) ...
$ ls -R um

  um: notes.txt

$ svn import um file:///public/svn/um -m "fp"

  Adding um/notes.txt
  Committed revision 1. 
Checkout project (using direct file mode) ...
$ svn co file:///public/svn/um

  A um/notes.txt
  Checked out revision 1.

$ ls -Ra

  .:         .  ..  um
  ./um:      .  ..  notes.txt  .svn
  ./um/.svn: .  ..  entries  format  prop-base  props  text-base  tmp
  ...

$ svn info um

  Path: um
  URL: file:///public/svn/um
  Repository Root: file:///public/svn
  Repository UUID: 2a33dff9-0b7b-49a1-a411-a1b6993661c1
  Revision: 2
  Node Kind: directory
  Schedule: normal
  Last Changed Author: rickatech
  Last Changed Rev: 2
  Last Changed Date: 2009-07-05 20:52:13 -0700 (Sun, 05 Jul 2009) 
Checkout project remotely ...
$ svn co file:///public/svn/um

$ svn co svn://192.168.2.24/um

  A um/notes.txt
  Checked out revision 1.

$ svn co svn://localhost/um

  ...  requires authentication, creates ~/.subversion user settings  ...

$ svn co svn co file:///public/svn/um

  ...  bypasses authentication, creates ~/.subversion user settings  ... 
Enable very simple user password authentication ...
# cd /public/svn

# ls -al

  conf
  dav
  db
  format
  hooks
  locks
  README.txt

# cd /public/svn/conf

# rcsdiff *

  diff -r1.1 passwd
  8a9,10
  > rickatech = 1234

  diff -r1.1 svnserve.conf
  11a12
  > anon-access = none
  18c19
  < # password-db = passwd
  ---
  > password-db = passwd

# service xinetd restart

  Stopping xinetd:  [  OK  ]
  Starting xinetd:  [  OK  ] 

Common commands ...

$ svn status

  M notes.txt

$ svn diff

  Index: notes.txt
  ================
  --- notes.txt	(revision 1)
  +++ notes.txt	(working copy)
  @@ -1 +1,3 @@
   This is a test!
  +
  +First change 

$ svn status -u

  *        public_htdocs/swfupload/swfupload.swf
  *        public_htdocs/swfupload
  *        public_htdocs/js/component_new.php
  *        public_htdocs/js/swfupload.queue.js
  *  223   public_htdocs/js/component_new.js
  *        public_htdocs/js/handlers.js
  *        public_htdocs/js/fileprogress.js
  *        public_htdocs/js/swfupload.js
  *        public_htdocs/js/swfupload_alt.js
  *  223   public_htdocs/js
  *        public_htdocs/XPButtonUploadText_61x22.png
  *  223   public_htdocs
  *  223   classes/ComponentNew.php
  Status against revision:    225

$ svn update

  A    public_htdocs/XPButtonUploadText_61x22.png
  A    public_htdocs/swfupload
  A    public_htdocs/swfupload/swfupload.swf
  D    public_htdocs/js/component_new.js
  A    public_htdocs/js/fileprogress.js
  A    public_htdocs/js/swfupload.js
  A    public_htdocs/js/swfupload_alt.js
  A    public_htdocs/js/component_new.php
  A    public_htdocs/js/swfupload.queue.js
  A    public_htdocs/js/handlers.js
  U    classes/ComponentNew.php
  Updated to revision 225.

$ svn delete foobar

  ... stay tuned ...

$ svn commit -m "some text description"

  ... stay tuned ... 
$ svn diff -r 1799:1800 email_tracker.php 

  [ show difference between past file versions ]

$ svn diff classes/Company.php -rBASE:HEAD 

  ... show diff of changes in head vs current local file? 

$ svn log summit-reg-barcode.php 

  ------------------------------------------------------------------------
  r2077 | ricks | 2009-10-01 10:42:53 -0700 (Thu, 01 Oct 2009) | 1 line

  size ...
  ------------------------------------------------------------------------
  r2075 | tobin | 2009-09-29 15:14:39 -0700 (Tue, 29 Sep 2009) | 1 line

  Updated ...
  ------------------------------------------------------------------------
  r2074 | ricks | 2009-09-25 14:34:55 -0700 (Fri, 25 Sep 2009) | 1 line

  as per ...
  ------------------------------------------------------------------------

$ svn diff -r2074:2075 summit-reg-barcode.php --diff-cmd diff -x -b

  23,24c23,24
  < $code->setScale(2); // Resolution
  < $code->setThickness(26); // Thickness
  ---
  > $code->setScale(4); // Resolution
  > $code->setThickness(30); // Thickness

  [ you can't do a diff between file versions in a
    tag/branch that doesn't contain both versions? ]

Review existing tags and branches.  Create a tag, delete a tag.

$ svn list https://svn.motmd.com/svn/foobar

  branches/
  tags/
  trunk/

$ svn list https://svn.motmd.com/svn/foobar/tags

  1.0.0/
  ...
  1.0rc3/

$ svn copy -m "Rick's patches" https://svn.motmd.com/svn/foobar/trunk https://svn.motmd.com/svn/foobar/tags/1.0.5

  ...

$ svn delete -m "poof" https://svn.motmd.com/svn/foobar/1.0.5

  ... 

Switch working files from trunk to branch.  This is a handy non-invasive way to see what files have changed since a branch was made.  Reverse the parameters to switch from branch back to trunk.

$ svn status

$ svn info | grep URL

  URL: .../svn/nimbus/trunk

$ svn switch .../svn/nimbus/tags/1.0.4

  D  public_htdocs/XPButtonUploadText_61x22.png
  D  public_htdocs/swfupload
  A  public_htdocs/flash
  A  public_htdocs/flash/swfupload_f9.swf
       ...
  U  nimbus.tmproj
  U  classes/ComponentNew.php

$ svn info | grep URL

  URL: .../nimbus/tags/1.0.4 
zap technologies
printable