Subversion

Switching from Git to SVN was tough, but I emerged from the ashes a better person: one with a much better mastery of bash, diff, patch and the art of manual version control.

A preview of what’s to come.

Get ready for some character building.

  1. revert to current working copy (git reset HEAD)
    svn revert -R .
    svn up
  2. untrack already delete file (git add –update)
    svn st | grep ^! | cut -b7- | xargs svn delete
  3. track all new files (git add -a)
    svn st | grep ^? | cut -b7- | xargs svn add
  4. merge changes from trunk (git merge)
    diff -ruN branch/ trunk/ > patch.diff
    patch -s -p0 < patch.diff
    # resolve conflicts and try again
  5. locate and merge changes one folder at a time
    #!/bin/bash
    
    branch_loc=/soft/branch/mybranch
    trunk_loc=/soft/trunk
    
    # subfix for diff files
    dsubfix=.diff
    
    # for each folder in src, make a diff file with lastest trunk
    # this will miss any new directories in trunk, 
    #  but they can be copied over directly
    cd $branch_loc/src
    src_folders=`ls -d */`
    for folder in $src_folders; do
     # create diff file for this folder
     prefix=src${folder%?} # strip the / at the end
     mydiff=${prefix}$dsubfix
     
     diff -ruN $folder $trunk_loc/src/$folder > $mydiff
    done
    
    # attemp to patch
    cd $branch_loc/src
    for mydiff in `ls | grep diff`; do
     # patch the diff file for this folder
     echo "uncomment to apply changes"
     #patch -t -p 0 < $mydiff 
    done