SVN - Subversion

From GLMWiki
Revision as of 12:27, 15 February 2010 by Kc8wxm (Talk | contribs)

Jump to: navigation, search

Important Note about versions

  • If you plan on using svn to update and commit files from devsys2 through samba you'll need to be sure that your client version is the same an what's on devsys2 (currently 1.5.1)
  • DO NOT USE a higher version client than this.
  • The vrs # pertains to the svn client and not the application using svn

This mean that if your working on your own development (sandbag) area on devsys2 you'll have no problems. But for the common server directories that we have setup for clients under /var/www/server we'll need to make sure that only command line svn on devsys2 is used to update the files.

Installing SVN

Windows

ubuntu

  • Installing svn under ubuntu
    • sudo apt-get install subversion

Mac

More Applications

Importing a Site

  • All sites will be placed under the prod directory of the svn repository
    • svn import [PATH] URL
svn import www.newsite.com http://cvs2/svn/prod/www.newsite.com

Checking Out a Site

Checking in your Changes

  • svn ci [PATH]
svn ci -m "some discriptive comment on what was changed" file1.xxx

Working on Site (Branching)

  • Working on a branched copy is not difficult first create a copy of the site in svn
    • svn copy SRC DST
    • SRC and DST should be URL's of the site to make a branch
svn copy http://cvs2/svn/prod/www.newsite.com -m "branch off from prod/www.newsite.com"

http://cvs2/svn/dev/www.newsite.com

  • You can call the copy anything. In case there's someone else with that site in dev directory just make a new name
svn copy http://cvs2/svn/prod/www.newsite.com http://cvs2/svn/dev/steve.newsite.taskId# -m "branch off from prod/www.newsite.com"
  • Check out the branched copy.
    • svn co URL [PATH]
svn co http://cvs2/svn/dev/www.newsite.com

Merging your work back into the Production (trunk)

  • to merge your copy of your working branch back into the main trunk you'll need to make sure that your work is commited first and then checkout a copy of the trunk.
    • svn co URL [PATH]
svn co http://cvs2/svn/prod/www.newsite.com
    • if you already have this then check that it is updated
    • svn update [PATH]
svn update www.newsite.com
  • You need to know at what point your last commited branch changes was at (what commit vrs #)
    • you can find out by running a svn log command
svn log --verbose --stop-on-copy http://cvs2/svn/dev/www.newsite.com
r98 | steve | 2010-02-03- 09:26:09 -0500 (Wed, 03 Feb 2010) | 2 lines
Changed paths:
 A /dev/www.newsite.com (from /prod/www.newsite.com:97)
branch off from prod/www.newsite.com
  • from this we now know the branch started at revision 98 to get our copy into the trunk we'll need to merge in our changes from revision 98 to the HEAD revision (trunk)
  • svn merge -r N:M SOURCE [PATH]
svn merge -r 98:HEAD www.newsite.com http://cvs2/svn/dev/www.newsite.com

Moving files or directories in SVN

  • svn move SRC DST
svn move http://cvs2/svn/www.oopswrongspot.com http://cvs2/svn/prod/www.nowitscorrect.com

Resolving Conflicts

Where to get more help

http://subversion.apache.org/docs/

Viewing What Gaslight has in SVN

http://cvs2/websvn websvn interface to svn repository

http://cvs2/svn direct to repository

Advanced Topics

  • changelist

svn client 1.5 and above can help you out by creating a kind of filter of changed files called a changelist if you have many files that you have worked on this changelist can help you group them. For example if you made changes to the site, one with changes for a upgrade to the Toolbox code and another with changes to a Photo gallery you can assign files into --changelist to keep them grouped together. This changelist can be used to run a svn command such as commit or diff.

svn status
M admin/Photos/list_photos.php
M admin/Photos/edit_photo.php
M Toolkit/Photos/Display.php
svn changelist Photo-Upgrades admin/Photos/list_photos.php admin/Photos/edit_photo.php Toolkit/Photos/Display.php
Path 'admin/Photos/list_photos.php' is now a member of Photo-Upgrades
Path 'admin/Photos/edit_photo.php' is now a member of Photo-Upgrades
Path 'Toolkit/Photos/Display.php' is now a member of Photo-Upgrades
svn status
--- Changelist 'Photo-Upgrades':
M admin/Photos/list_photos.php
M admin/Photos/edit_photo.php
M Toolkit/Photos/Display.php

You can view the changelist in svn status anytime and then commit days or weeks later by committing the entire list:

svn ci -m "upgrading Photo App" --changelist Photo-Upgrades
Sending     admin/Photos/list_photos.php
Sending     admin/Photos/edit_photo.php
Sending     Toolkit/Photos/Display.php
Transitting file data ...
Committed revision 159.

NOTE: each file can only belong to one changelist at a time. If you assign a file that is already in a changelist svn will warn you that it is going to be removed from one changelist and added to the new one.

You can remove files from a changelist:

svn changelist --remove admin/Photos/edit_photo.php
Path 'admin/Photos/edit_photo.php' is no longer a member of a changelist.