SVN usage details

From GEANT2-JRA1 Wiki

Contents

Read Only Access

If you only need read access, please see the public Anonymous Source Code Access instructions.

Commit Access

  1. We ask that only those people who will be actively modifying code ask for commit access.
  2. Accounts MUST be tied to individuals, not groups or organizations.
  3. Accounts can be requested using bugzilla (You must have a bugzilla account to do this.)
    • After an account is requested, a temporary passwd will be assigned. You will then need to access the "user management web site" to change your passwd and add the following contact information:
      1. email
      2. org
      3. fullname
      4. phone
  4. Once you have set a new passwd, and provided your contact information, you can request that your SVN account be granted RW access using bugzilla
  5. Once your RW access has been granted, you can check-out perfsonar for editing:
    svn co https://svn.perfsonar.net/svn/perfsonar/trunk/perfsonar
  6. Email lists for log messages will be set up soon. Any interested party will be able to request these log messages be sent to them.

SVN Client configuration of automatic properties

  1. Edit person SVN config file
    • On Linux/MacOS X/Unix edit file ~/.subversion/config
    • On Windows edit file "%HOMEDRIVE%%HOMEPATH%\Application Data\Subversion\config"
    • For editing system wide configuration please take a look at SVN Book located at http://svnbook.red-bean.com/

  2. Find section [miscellany] and uncomment it if commented
  3. Under the [miscellany] section find enable-auto-props and uncomment it if commented and set it to 'yes'
  4. Find section [auto-props] and uncomment it if commented
  5. Comment everything under [auto-props] section
  6. Add the following lines under [auto-props] section:
  7. *.c = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.cc = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.cpp = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.h = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.hpp = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.pl = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.py = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.java = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.xml = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.dsp = svn:eol-style=CRLF;svn:keywords=Author Date Id Revision
    *.dsw = svn:eol-style=CRLF;svn:keywords=Author Date Id Revision
    *.sh = svn:eol-style=native;svn:executable;svn:keywords=Author Date Id Revision
    *.txt = svn:eol-style=native;svn:keywords=Author Date Id Revision
    *.png = svn:mime-type=image/png
    *.jpg = svn:mime-type=image/jpeg
    Makefile = svn:eol-style=native;svn:keywords=Author Date Id Revision
    
  8. If there are other file extensions, that I didn't mention here, please add them and let me know about them (jra1-sw 'at' arnes.si)
  9. For Eclipse IDE, follow the procedure mentioned above for Windows

Basic SVN commands using the svn command-line client

Creating new branch directory

 svn mkdir https://svn.perfsonar.net/svn/perfsonar/branches/new_branch 
 svn cp https://svn.perfsonar.net/svn/perfsonar/trunk/perfsonar \
        https://svn.perfsonar.net/svn/perfsonar/branches/new_branch/perfsonar
Checking out the code 
svn co https://svn.perfsonar.net/svn/perfsonar/trunk/perfsonar
Updating your code with what is in the repository 
(from the local perfsonar working dir) svn update
Adding new directories 
svn mkdir A
Adding new files 
svn add [files] (Files must have already been created.)
Deleting a file 
svn rm filename
Checking code back in 
(from the local working dir) svn ci

SVN Basic Work Cycle

There is a very good explaination for how developers are expected to work with the source code in the SVN book.

Also, for users already familiar with CVS, there is a Cross-over Guide that explains how to do things with SVN relative to the way you used to do them.

Short Reference for Subversion - Most important commands

svn checkout https://URL/to/repository/trunk [dirname] (svn co)
---------------------------------------------------------------

Checks out the current state of the repository into a directory named 
"dirname" which is newly generated. If "dirname" is omitted a new directory 
is created named "trunk". This directory can be removed safely at any time, 
as it is only a local copy of the repository. Ususal Unix commands do not 
have an effect on the repository! 
Note: single files cannot be checked out, the URL must point to a directory.
With the -r flag, a revision number can be specified to check out an older 
version.  


svn update
----------

Updates your local copy to the current state of the repository. The following
letters can show up:

U foo	foo was updated
A foo	foo was added
D foo   foo was deleted
R foo   foo was replaced by another foo
G foo   foo was merged
C foo   a conflict occurs: my changes and changes from the repository, 
        someone else checked in while I was editing my local copy are 
        overlapping.


svn add foo
-----------

Foo will be checked in as new file with the next commit to the repository.
If foo is a directory, it is added recursively (with content). If you want 
to add it without content specify --non-recursive or -N.


svn delete foo
--------------

Foo will be deleted from the repository with the next commit.


svn copy foo bar
----------------

Bar is created as a copy from foo and added to the repository with the next
commit.


svn move foo bar
----------------

Like svn copy, but foo will be deleted in the repository.


svn status
----------

Gives an overview of all changes made in comparison to the local check out.
Comparison to the current repository is done by specifying the -u flag. The following letters can show up:

A file_or_dir	file_or_dir is scheduled for adding
C file		a conflict occurs (see above)
D file_or_dir	file_or_dir is scheduled for deletion
M file		file was changed
X dir		not in version control but with extern definition (see 
		handbook for more information)
? file_or_dir	not in version control
! file_or_dir	in version control, but missing or incomplete
~ file_or_dir	in version control, but file type differs (for example: a
		directory in version control, but a text file in the local
		copy)
I file_or_dir	will be ignored by Subversion


svn diff
--------

Reports changes in diff format.


svn revert [file]
-----------------

Undo changes (recovers current checked out state).


svn commit [file] (svn ci)
--------------------------

Sends all changes to the Subversion server. The Revisionnumber is incremented
by 1. You should provide a log messaage describing the changes. It can be 
added by specifying --message "logmessage" or -m "logmessage" or from a file
with --file. If nothing is specified, an editor is opened, to type the log
message in.

 
Create Branches
---------------

Make your own branch by performing the following steps:
- make a copy of the trunk in the branches directory:
  svn copy trunk branches/[name-of-my-branch]
- commit to add the branch to the repository:
  svn commit -m "My brand new shiny branch!"
or do it the short way:
  svn copy https://URL/to/repository/trunk 
           https://URL/to/repository/branches/[name-of-my-branch]
           -m "My brand new shiny branch!"
To checkout a branch specify "branches/[name-of-branch]" instead of "trunk".


More commands:
--------------

svn blame:	Shows author and revision information
svn cat:	Shows the content of files in the repository
svn cleanup:	Cleans up the working copy (needed in case of incomplete svn
		actions)
svn export:	Exports a directory tree
svn help:	Hopefully helps
svn import:	Imports a directory tree
svn info:	Reports a lot of information about the specified directory
svn list:	Like ls
svn log:	Shows log messages
svn merge:	Merges two different versions of a file
svn mkdir:	Creates a new directory and schedules it for adding
svn propdel:	Deletes a propert (*)
svn propedit:	Edits a property (*)
svn propget:	Returns the value of a property (*)
svn proplist:	Lists all properties (*)
svn propset:	Sets a property (*)
svn resolved:	Resets the "conflict" status
svn switch:	Changes the working copy to a branch

(*) Properties: ead Handbook. For example a property can be set to ignore a certein file.

SVN tips

  1. Removing files from a branch
    • When removing files from a branch, it will make more difficult to merge back in to the main line. (You will need to make sure you do not remove the files on the merge.)
    • It is no problem to remove these files on the branch you are currently using - but this way of working in SVN could make it a bit more difficult in the long-term. (If it is worth it to you to have the files out of the way, then go ahead. But, please do be careful if you need to merge back in to trunk.)
Personal tools