Difference between revisions of "Slicer3:SVNIntro"

From Slicer Wiki
Jump to: navigation, search
(Created page with '== What is the Slicer 3 SVN repository? == The Slicer 3 source code revision control repository is is managed using "[http://en.wikipedia.org/wiki/Subversion_(software) Subvers…')
 
(conflict link)
Line 112: Line 112:
 
   svn status | grep "C "
 
   svn status | grep "C "
  
[[Engineering:Subversion_Repository#Conflicts_in_the_file| See ]]  on how to resolve conflicts  
+
[[Slicer3:SVNIntro#Conflicts_in_the_file| How to resolve conflicts ]]
  
 
* Update and compile libraries in Slicer3-lib by executing   
 
* Update and compile libraries in Slicer3-lib by executing   

Revision as of 20:37, 18 June 2010

Home < Slicer3:SVNIntro

What is the Slicer 3 SVN repository?

The Slicer 3 source code revision control repository is is managed using "Subversion".

For information on how to use Subversion, please see the SVN Book at red-bean.com. In particular, check out the information about the Basic Work Cycle for svn.

How do I get Slicer 3 source code?

First, you should install a Subversion client on your computer. They are available for most operating systems. Please check if you already have Subversion on your system, or download an appropriate one from http://subversion.tigris.org/project_packages.html. On Linux and Cygwin platforms you simply need to check if the "svn" command is available.

Once you have a subversion client, you can checkout the Slicer 3 source code by using the following command:

svn checkout http://svn.slicer.org/Slicer3/trunk Slicer3

How do I commit to the Slicer 3 repository?

Fill out the form at https://www.kitware.com/Admin/SendPassword.cgi and under Comment type "Request password for Slicer3 SVN". Once you have access to write to the Slicer 3 svn repository, you can work with the repository using the following commands:

To update your local copy from the repository:

svn update

To check the current state of your edits:

svn status

To check the current state compared to the repository:

svn -u status

To add a new file:

svn add filename

followed by (very important):

svn commit -m "ENH: Adding a new file" filename

To remove a file:

svn remove filename

To rename file:

svn move oldname newname

If the update results in conflict, fix the file first before commiting it.

Once you have fixed the file:

svn resolved <filename>

Can I see the files through a web interface?

Yes, see: ViewVC.

How do I make a release branch?

Use the copy command like:

svn copy http://svn.slicer.org/Slicer3/trunk/ http://svn.slicer.org/Slicer3/branches/MyBranch -m "ENH: new branch to capture work done by me for this project"

How can I switch between branches and the trunk?

You can switch your current checkout to the branch with:

svn switch http://svn.slicer.org/Slicer3/branches/MyBranch

and get back to the head with:

svn switch http://svn.slicer.org/Slicer3/trunk 

Once you have switched, you can do updates and commits to that branch.

Merging latest changes from the HEAD into your branch

svn merge http://svn.slicer.org/Slicer3/trunk http://svn.slicer.org/Slicer3/branches/MyBranch/Slicer3

Note: this will not get new files, just changes to existing files.

How can I tell if I'm on the branch or the trunk?

Look at the URL line from

svn info


How can I merge changes from one branch into another?

To move changes from the current trunk head into a branch see this part of the svn documentation or follow the instructions below:

  • Find out the initial version number of the branch by executing:
svn log --verbose --stop-on-copy http://svn.slicer.org/Slicer3/branches/MyBranch

from which you'll see a revision number for the commit that created the branch. The number is specified by the oldest (last) log entry and starts with an r, for example r2137.

  • Find out the current revision number of the trunk by executing
svn update 

In my example it is 2157.

  • To bring changes up through 2157 into the branch, you run the following command from within the directory that has the branch:
svn merge -r2137:2157 http://svn.slicer.org/Slicer3/trunk

If you do 'svn status' the new files will show up as modified and/or conflicts.

  • Resolve any conflicts:
 svn status | grep "C "

How to resolve conflicts

  • Update and compile libraries in Slicer3-lib by executing
 Slicer3/Scripts/genlib.tcl
  • Compile Slicer3 by executing make in Slicer3-build
  • Commit all new files (also the ones that were added/updated from the trunk) to the branch by executing the following command in the source directory :
svn commit -m "ENH:  Update my branch with current trunk - r2137:2157" 

Note, add r2137:2157 in the log file so next time you update the branch by executing

svn merge -r2158:XXXX http://svn.slicer.org/Slicer3/trunk

I get the following error when I try to commit...

If you want to enable this error reporting on your subversion repository, please follow instructions about Subversion Input Filters.

Commit log error

The error would look like this:

---------------------------------------------------------------------
 Subversion Commits to Slicer3 require commit type in the comment.
 Valid commit types are:
   BUG:   - a change made to fix a runtime issue
            (crash, segmentation fault, exception, or incorrect result,
   COMP:  - a fix for a compilation issue, error or warning,
   ENH:   - new functionality added to the project,
   PERF:  - a performance improvement,
   STYLE: - a change that does not impact the logic or execution of the code.
            (improve coding style, comments, documentation).
 
 The Subversion command to commit the change is:
 
   svn commit -m "BUG: fixed core dump when passed float data" filename
 
 you can also use the syntax below which omits the -m flag. In this case
 subversion will start up an editor for you to enter a comment on why you made
 the change.
 
   svn commit filename
 ----------------------------------------------------------------------

Make sure to start the commit message with one of the specified tags.


Tabs in the source file

----------------------------------------------------------------------
 Problems in file "my baby.cxx":
 The following line(s) contain tabs:
     4: This line contains a tab-->      <--
 
 Found problems with 1 file(s). Cannot commit
 ----------------------------------------------------------------------

Make sure there is no tabs in the source files. You can remove them with

perl -pi .-e 's/\t/    /g' <FileName>

or

 sed -i -e 's/\t/  /g' <FileName>

Windows new-lines in the source file

----------------------------------------------------------------------
Problems in file "trunk/AnalyzeObjectReader/objectutils.h":
The following line(s) contain windows new-lines:
    1: /*************************************************************************
    2: Copyright (c) 2007, Regents of the University of Iowa
    3: 
    4: All rights reserved.
    5: 

Found problems with 1 file(s). Cannot commit
 ----------------------------------------------------------------------

Make sure there are no windows new-lines in the source files. You can remove them with

 sed -i -e 's/^M//g' <FileName>

where the "^M" is typed by pressing the control key with the v-key followed by control key with the m-key.

Missing new line at the end of file

----------------------------------------------------------------------
 Problems in file "my baby.cxx":
 The following line(s) do not contain new-line character:
     5: another linex
 
 Found problems with 1 file(s). Cannot commit
 ----------------------------------------------------------------------

Make sure there is a new line at the end of the source file. Most editors should fix this automatically.

Conflicts in the file

----------------------------------------------------------------------
 Problems in file "test.cxx":
 The following line(s) contain conflicts:
     1: <<<<<<< .mine
    11: =======
    22: >>>>>>> .r13
 
 Found problems with 2 file(s). Cannot commit
 ----------------------------------------------------------------------

Make sure to remove any conflicts before removing files.

Once resolved:

svn resolved test.cxx

Things missing from SVN that were in CVS

No cvs diff -w

Some workarounds here: http://kitt.hodsden.com/ignoring_whitespace_changes_with_svn_diff

No cvs update -C

Remove the file and then update (nothing more clean?) (mathieu). I believe this is describe here: http://svnbook.red-bean.com/nightly/en/svn.tour.cycle.html#svn.tour.cycle.resolve

...snip...

If you get a conflict, you need to do one of three things:

  • Merge the conflicted text “by hand” (by examining and editing the conflict markers within the file).
  • Copy one of the temporary files on top of your working file.
  • Run svn revert <filename> to throw away all of your local changes.

Once you've resolved the conflict, you need to let Subversion know by running svn resolved. This removes the three temporary files and Subversion no longer considers the file to be in a state of conflict.

$ svn resolved <filename>

...snip...

Acknowledgements

Modified from NA-MIC Engineering:Sandbox.