Sunday, January 1, 2012

Subversion quick configuration

1.1 Create a folder to hold all repositories
$ mkdir ~/.svnroot

1.2 Create a repository
$ svnadmin create ~/.svnroot/project

2.1 Import the repository to work with it (only necessary to do it once)
$ svn checkout file:///home/pron/.svnroot/project

2.2 Create the main structure (only necessary to do it once)
$ cd project
$ mkdir trunk tags branches

3. Activate daemon to allow access to Subversion repositories using the svn network protocol
$ svnserve -d -r ~/.svnroot

4.1 Make a backup of a repository
$ svnadmin dump -q ~/.svnroot/project > project.dump

4.2 Restore a backup
$ svnadmin create project
svnadmin load project < project.dump

5.1 Creating a version
$ svn copy file:///home/pron/.svnroot/project/trunk \
> file:///home/pron/.svnroot/project/tags/v0.1 \
> -m "Creating v0.1 with the right command"

6.1 Recover the last version of a file that has been saved but no commited
$ rm file
$ svn up file


6.2 SVN Diff against changes in the remote repository 
$ svn diff -r HEAD

6.3 How to ignore a directory with SVN
$ svn propedit svn:ignore .

If you have multiple things to ignore, separate by newlines in the property value. In that case it's easier to edit the property value using an external editor:
$ svn propset svn:ignore dirname .

6.4 Getting SVN revision number into a program automatically
Add this code to your file (i.e. file.py)
VERSION='$Rev$'

After this, in the command line write this:
$ svn propset svn:keywords "Revision" file.py


Resources
http://svnbook.red-bean.com/en/1.1/ch04s06.html
http://stackoverflow.com/questions/116074/how-to-ignore-a-directory-with-svn http://stackoverflow.com/questions/1449935/getting-svn-revision-number-into-a-program-automatically

No comments: