svn commands within a working copy
subversion server with ssh
Creating a repository
Symlinks
My Setup
Issues
Rollback
Subversion Manual
TODO Speedy Bash Prompt: Git and Subversion Integration Bedazzle Your Bash Prompt with Git Info
Add a file/directory
svn add file
Delete a file
svn ci . -m ""
svn delete file
svn ci . -m ""
Use a wild card
svn add *
To kill local directories changes
svn revert
To restore them, rename the directory,
update to get the old directory back and then
fix.
For fine grain changes only revert individual files
svn revert ./._.DS_Store
svn status
svn revert */Makefile - to revert multiple files using Bash expansion
Check for differences(local). e.g.
svn status compare current againt
revison 133's version
M helix.cpp
M helix.h
svn status | grep -v ?
svn diff filename
svn diff -r 133 filename
svn status --show-updates shows the latest revision number
svn status -u
Moving files
svn cp file file2
svn del file
svn ci . -m ""
Compare working copy to Repository
svn status --show-updates produced
* 68 j013.js
Status against revision: 69
svn log | head does not get the updated log!
Comparing directories
svn status -v -N non recursive look
svn list -v global
svn log -r 139 -v gave me a list of the files that were committed in that revision
svn log -r 135:139 -vgave me the recent history of file changes given my current revision number 139.
svn log file
does not kill unmodified modified files*
svn blame file
svn update
An update or status has the file's state: U for updated, A for added, ? if it has no idea,
M for modified, G for merged on update and C for conflict.
In the event of a conflict, one possibility is to throw away the local changes.
svn revert filename
To edit the merge by hand edit the filename and then
svn resolved filename
I used diff tools to see the differences, as context/meaning can be the issue.
List the contents of the repository.
svn ls file:///home/svnaccount/repository
Look at files log
svn log file:///home/svnaccount/repository/trunk/polytrimon/polytrimon.h
Repository Backup
mkdir /media/KINGSTON/repository2008-09-13
svnadmin hotcopy /home/svnaccount/repository /media/KINGSTON/repository2008-09-13/
To restore copy the backup repository to where the repository lives.
svn co file:///home/svnaccount/repository/trunk/base
checks out base from the trunk.
Access repository from 10.1.1.7.
svn list svn+ssh://zero@10.1.1.7/home/svnaccount/repository
Create account on server with automatic ssh login so svn+ssh is automatic.
The use of svn+ssh can be minimized by checking out the repository
and then using local commands (normal simple svn syntax). e.g.
svn co svn+ssh://harry2@10.1.1.7/home/svnaccount/repository/trunk/polytrimon
Edit polytrimon.h file, check the changes back in.
svn ci . -m ""
To check out my source code tree from home
svn co
svn+ssh://zero@10.1.1.7/home/svnaccount/repository/trunk/base base
Created a svnaccount and svngroup.
At home directory
/home/svnaccount/
$ svnadmin create repository
$ svn import polytrimon /home/svnaccount/repository/trunk/polytrimon
$ mkdir temp
$ cd temp
$ svn co file:///home/svnaccount/repository
$ cd repository
$ mkdir branches
$ mkdir tags
$ svn add branches
$ svn add tags
$ svn ci . -m ""
Changed the svnaccount to have primary group svngroup.
Give permission for other users in the group to read and write.
# chmod -R 770 /home/svnaccount/repository
Tested by having another user who belongs to the svngroup check out the repository,
edit a file and check the file back in.
So each client user needs a local account that includes the svngroup. So you need to log in to the server before you can access svn and hence the repository is (hopefully)secure.
Wouldn't it be nice if subversion followed your symlink (if you told it to do so through an option switch) ... Well it doesn't - without some considerable work (externals crap) - How to make svn follow symbolic links?, External Definitions Chapter 3.Advanced Topics
In situations like this I turn to the OS. Since SVN likes all the source in one tree store all source in one tree. Then use a script to copy the code into the other locations.
Here is my bash script export.sh . I first created the
/var/www/html directory with writable permissions.
#/bin/sh
# Inside base/p1/comsci/php/html
rsync -avz ../html/ /var/www/html/
rm /var/www/html/export.sh
When changes are made to the source the script needs to be executed.
For projects that share multiple source code - and do not have ownership here is a technique. Have two scripts - one to copy to the target location, another to copy from the target location. Use a common naming convention for the scripts like import.sh and export.sh .
Now to keep the current state use the import.sh to take a snapshot. So from the projects perspective it has a complete picture/copy of source of all the software - under version control!
When it comes time to deploy you are in a much better situation. Firstly you have all your code versioned. If conflicts occur deal with them. Use diff tools.
Note that the issues subversion faces are inherent in how
it manages the structure. Each directory has a .svn folder so
subversion is not separate from the source. If this directory
was engineered to handle multiple repositories which I believe it
is not then it would be easy to add the follow symbolic link flag.
e.g. Hypothetical
$ svn add -follow directory/file
Alternatively the technique I described should do the job.
The problem for subversion is its lack of support for multiple repositories. Branches hang around, the developer wants to take a copy of the repository - experiment then possibly merge the changes(history etc) back in, possibly with different repositories.
This is on top of the previous problem of repositories not working with each other.
svn co svn+ssh://zero@10.1.1.7/home/svnaccount/repository/trunk/base
Better way to revert to a previous SVN revisio of a file? roll back a file.
e.g.
move to svn directory
$ svn blame <file>
svn merge -r 469:465 <file>
check in
Move back in time, checked out rollback directory to temporary place, removed files for rollback and copied the correct files.
While rollback is often accomplished with merge, this technique is more primitive where you piece together the files - you are in control. For example if you stuff up a merge then you now have another problem. [This technique suggested to me by Andrew Hazon when working with TN backup software - where in place restoration can fail, defensive strategy to live another day]
Here is an example where I rolled back the changes
svn log menucontents.js found revision number
cd ~/Desktop/temp
svn co -r263 svn+ssh://zero@10.1.1.7/home/svnaccount/repository/trunk/base/p1/comsci/javascript/j021
rm -Rf j021/.svn
move to true j021 directory, remove files, including files added to repository
svn del somefile
cp ~/Desktop/temp/j021/* .
svnci - my helper check in function
While this works the issue of lost history and duplicate data in repository is not good. What is the proper way of implementing rollback?