10/20/2008

Some Commands of SVN

Context: We have a new project named Odour

Get Svn help

$ svn help 

Get sub-commands' help

$ svn help add 

Import a new Project

$ cd ~/project
$ mkdir -p Odour/{trunk,branches,tags}
$ svn import svntest https://localhost/svn/Odour --message "Start project"
$ rm -rf Odour

The aim of this operation is to build a new project named Odour, there are three sub-directory in this project involved trank, branches, and tags. Then you should delete the Odour when you have imported the project to our repository named https://localhost/test/svntest

Checkout a project

$ svn checkout https://localhost/test/svntest/trunk --username= yourname

Some example about the reversion

$ svn diff --revision PREV:COMMITTED foo.php
# shows the last change committed to foo.php

$ svn log --revision HEAD
# shows log message for the latest repository commit

$ svn diff --revision HEAD
# compares your working file (with local changes) to the latest version
# in the repository

$ svn diff --revision BASE:HEAD foo.php
# compares your “pristine” foo.php (no local changes) with the
# latest version in the repository

$ svn log --revision BASE:HEAD
# shows all commit logs since you last updated

$ svn update --revision PREV foo.php
# rewinds the last change on foo.php
# (foo.php's working revision is decreased)

$ svn checkout --revision 3
# specified with revision number

$ svn checkout --revision {2002-02-17}
$ svn checkout --revision {15:30}
$ svn checkout --revision {15:30:00.200000}
$ svn checkout --revision {"2002-02-17 15:30"}
$ svn checkout --revision {"2002-02-17 15:30 +0230"}
$ svn checkout --revision {2002-02-17T15:30}
$ svn checkout --revision {2002-02-17T15:30Z}
$ svn checkout --revision {2002-02-17T15:30-04:00}
$ svn checkout --revision {20020217T1530}
$ svn checkout --revision {20020217T1530Z}
$ svn checkout --revision {20020217T1530-0500}

Update

$ svn up

add


$ svn add foo.file
$ svn add foo1.dir
$ svn add foo2.dir --non-recursive
$ svn delete README

Conflict

The svn will create three files named .mine, .rOLDREV, .rNEWREV separately When the workcopy have confict with header version, for example:

$ ls -l
sandwich.txt
sandwich.txt.mine
sandwich.txt.r1
sandwich.txt.r2

There are there method to resolve this confict.

Method A: modify the sandwich.txt, then run:

$ svn resolved sandwich.txt

Mehtod B: use the header version to override your version

$ cp sandwich.txt.r2 sandwich.txt
$ svn resolved sandwich.txt

Method C: use revert

$ svn revert sandwich.txt
Reverted 'sandwich.txt'
$ ls sandwich.*
sandwich.txt
Then , you can submit your workcopy
$ svn commit --message "Correct some fatal problems"
$ svn commit --file logmsg
$ svn commit

Clean Up
svn cleanup

Build branch

Method A: local build

$ svn checkout http://svn.example.com/repos/calc bigwc
A bigwc/trunk/
A bigwc/trunk/Makefile
A bigwc/trunk/integer.c
A bigwc/trunk/button.c
A bigwc/branches/
Checked out revision 340.

$ cd bigwc
$ svn copy trunk branches/my-calc-branch
$ svn status
A + branches/my-calc-branch

$ svn commit -m "Creating a private branch of /calc/trunk."
Adding branches/my-calc-branch
Committed revision 341.

Method B:remote build

$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/my-calc-branch \
-m "Creating a private branch of /calc/trunk."

Committed revision 341.

Swith to branch from trunk

$ cd calc
$ svn info | grep URL
URL: http://svn.example.com/repos/calc/trunk
$ svn switch http://svn.example.com/repos/calc/branches/my-calc-branch
U integer.c
U button.c
U Makefile
Updated to revision 341.
$ svn info | grep URL
URL: http://svn.example.com/repos/calc/branches/my-calc-branch

Build a tag
$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/tags/release-1.0 \
-m "Tagging the 1.0 release of the 'calc' project."

$ ls
my-working-copy/
$ svn copy my-working-copy http://svn.example.com/repos/calc/tags/mytag
Committed revision 352.

Delete a branch

$ svn delete http://svn.example.com/repos/calc/branches/my-calc-branch \
-m "Removing obsolete branch of calc project."

Create a new repository

$ svnadmin help
...
$ svnadmin help create
...
$ svnadmin create bdb /usr/local/repository/svn/test
$ chown -R svn.svn /usr/local/repository/svn/test

No comments: