Working with SVN
(This began a copy of WorkingWithCVS; bear with us as it is updated for SVN)
Subversion (SVN) Basics
This node discusses the basics of using SVN.
For information on more advanced usage, see:
- WorkingWithSVNBranches - making branches and merging between them
SVN stores source code in a shared repository (in our case on Sourceforge's server). The repository contains all past and present versions of the code, and is shared by everyone.
Your Working Copy
To work with the source code, SVN requires you to check out a working copy. This copy is private, so you can make and test any changes you like without disturbing anyone else.
If you have write access to the repository, when you are finished making your changes, you may commit your changes to the shared repository, making them available to everyone.
Alternately, you may generate a file containing the changes you made (a diff), and send it to a developer with write access to be incorporated.
You can check out as many working copies as you want; they take up only your own disk space, and they are completely independent of each other.
If you no longer need a working copy, you may simply delete it.
How Do I Check Out a Working Copy?
To check out a copy of Inkscape from the SVN repository, you may use the following command:
svn checkout https://svn.sourceforge.net/svnroot/inkscape/inkscape/trunk inkscape
Here are what the options mean:
"checkout" ("co" means the same thing) specifies the action to take (check out a working copy).
"https://svn.sourceforge.net/svnroot/inkscape/inkscape/trunk" is a repository URL; in this case, it refers to the "main" development branch for Inkscape. Other repository URLs are:
- http://inkscape.svn.sourceforge.net/svnroot/inkscape/doc-docbook/trunk - contains the docbook source of the Inkscape tutorials
"inkscape" is the name of the directory to check out into
You should have a complete working copy in the inkscape directory. You can cd to it and try compiling.
- Note: If it is a fresh checkout, you will need to run the ./autogen.sh shell script at the top level to create files needed to compile
When you're inside the working copy, you won't normally need to specify the repository URL, because SVN remembers where the working copy came from.
Note that a Subversion command only applies to the current directory and (possibly) any subdirectories. Normally (particularly for updates, diffs, and checkins), you will want to run the command from the top level of the project.
Bringing Your Working Copy Up-To-Date
Your working copy will not automatically include changes others have made to the repository since you checked it out.
To update your working copy, use this command:
Dealing with Conflicts
If you've made changes to your working copy, what happens if you update after someone has commited changes to the same files?
Normally, SVN can work this out on its own. Sometimes you have to help it along, though. If SVN says there were conflicts, look for which files have a C next to them in its progress output. Some of those may have unresolved conflicts. You can also search for '=======' in the files themselves to find any unresolved conflicts.
<<<<<<< filename The changes in your version will be here ======= The changes by the other person will be here >>>>>>> some version here
Sometimes you will keep one set of changes and discard the other, and sometimes you will combine the two. It will require a judgement call on your part either way. Talk to the person who made the other set of changes or ask on the mailing list if it's unclear what's going on. Remember that SVN is no substitute for communication.
Also, always make sure to build and test after an update to make sure that the combined changes work as intended!
Generating a Diff
(Always update before generating a diff!)
From the top-level directory, run the command:
svn diff -x -u3 > filename
-x -u3 specifies which format to use (a unified diff with three lines of context). This is the recommended diff format.
This will create a file describing the changes you have made, though if you have created new files as part of your changes, you will need to include those separately too when emailing them to the list or another developer for inclusion.
Automatic Commit Diff
[ fixme: how to do this in SVN?
SVN_EDITOR instead of CVSEDITOR
To always generate a diff when you commit to CVS, set the environment variable "CVSEDITOR" to the following script:
#!/bin/bash # get rid of redhat 9 locale ugliness unset LC_CTYPE # Turn on ro access (to stop multiple locks) for local roots grep @ CVS/Root >/dev/null 2>