User Tools

Site Tools


subversion-howto

This is an old revision of the document!


Checking Out and Updating

How do I check out the OOFEM Subversion repository?

Note: the repository at https://www.oofem.org/svn/ is only for OOFEM developers. Non-developers should use http://www.oofem.org/svn/ instead. For browsing the repository with a web browser, use http://www.oofem.org/websvn/.

To check out the OOFEM repository, you do the following:

svn co https://www.oofem.org/svn/trunk 

That will check out the whole OOFEM trunk and store it in local directory trunk.

How do I check out a specific tag?

To check out a specific tag or branch, you do:

svn co https://www.oofem.org/svn/tags/rel-1.8

This will check out the rel-1.8 release

To find out which tags and branches are available you can browse the repository via the web interface http://www.oofem.org/websvn/ or using:

svn ls https://www.oofem.org/svn/tags

How do I update my checked out version?

To update your working dir, all you have to do is run:

svn update

from inside it, just as you did with CVS.

Now that I have the source, how do I build OOFEM?

Have a look at the installation guide.

Editing Files and Committing

Editing files

Editing files with Subversion is no different than doing so with CVS.

To see which files you've edited do:

svn status

This is a very fast operation as it does not contact the remote repository (and does not bring the repository to the HEAD level).

Committing changes

The only difference you should know about is that Subversion does atomic commits, and you are encouraged to make your commits complete.

In other words, suppose you add a new file to Subversion and you update element.h. You should first svn add the new file, and then commit both it and element.h, in one go. That way, anyone doing a checkout cannot possibly get a revision in which one change had happened but not the other. To commit just do:

svn commit

Renaming and copying files and directories

One of the advantages of Subversion over CVS is that you can rename and copy files and directories without loosing the history. You simple do:

svn mv oldname.h newname.h
svn commit newname.h

Reverting changes

If you want to undo some changes you've made but not yet committed, try this command:

svn revert

If you did commit your changes, you can do this:

svn merge -r COMMITTED:PREV

(type COMMITTED and PREV, in capitals, as shown).

Correcting commit log messages

If for some reason when you commit a change you don't put the proper (or complete) information into the commit log message, you can correct it. Get the revision number of the commit with the incorrect message (for example, 9915), and then:

svn propedit svn:log --revprop -r 9915 https://www.oofem.org/svn/

This will open an editor window (using $EDITOR) and let you correct your mistakes, and then commit the change. Keep in mind that these properties are unversioned, meaning once you change it, the original version is gone.

Resolving conflicts

It might happen that an svn update will update a file you just edited and that the conflicts could not be automatically resolved. In that case the file will contain conflict markers “«««<” and “»»»>” and you have to edit the file to remove the conflict. Before being able to commit this file you first have to tell svn that the conflict has been resolved:

svn resolved myfile.C

Only then can you proceed to commit the file.

Branching and Tagging

What's the difference between branches and tags in Subversion?

There are no differences between branches and tags in Subversion. In fact, Subversion doesn't even know the concept of branches or tags: everything is a file or a directory for it.

A branch or a tag is nothing more than a copy of your files under a different path. It is an O(1) operation in time and disk space, so there's no harm copying everything.

How does the OOFEM repository do branches and tags?

OOFEM uses the following scheme for its branches and tags:

  • /branches: contains development, temporary branches. This is where unstable features are developed before they are merged into /trunk.
  • /tags: contains all official tags. That is, when a public release is make a tag here to mark the revision in which it happened.

In /branches and /tags, the naming convention used is like this:

  • /branches/branchname, (example /branches/iga-branch)
  • /tags/releaseversion (example: /tags/rel-1.8)

/branches has no naming convention, but we ask you to give your branches meaningful names. Names like “my-cool-branch” aren't very descriptive, whereas “new-schema-evolution” is. Please remember to erase your work branches after you're done.

So, how do I create a branch or copy of my work?

In order to create a branch or a tag, you must have /branches or /tags checked out, even if not recursing (-N).

If your dev's directory doesn't exist yet, create it:

svn mkdir branches/mybranch

Now copy the trunk:

svn cp trunk branches/mybranch

Of course, this will include the full OOFEM, but there's no harm in doing so. Creating the branch directly on the server

You can also create the branch directly without having a checked-out working copy:

svn cp https://www.oofem.org/svn/trunk \
       https://www.oofem.org/svn/branches/mybranch

The branch is now a identical copy of trunk, and you can check out mybranch. When you are done, you can merge the changes back to trunk. If your work takes a long time, you can easily merge changes from trunk into your working branch to stay in sync with the current development on trunk. This will also make merging your changes back to trunk much easier, as the only differences between trunk and your branch are the actual changes you have done to the branch.

You can read more about branching and merging in the book “Version Control with Subversion” in chapter four at http://svnbook.red-bean.com/en/1.4/svn.branchmerge.html.

Working with Branches

Getting information about the working directory

Where am I? I am about to check in my local files - will they end up on my branch or destroy the trunk?

You can ask your current directory what part of the subversion repository it corresponds to. svn info will tell you the directory's URL, the current revision, and when the last change occurred within the current directory:

$ svn info
Path: .
URL: https://www.oofem.org/svn/branches/mybranch
Repository UUID: 27541ba8-7e3a-0410-8455-c3a389f83636
Revision: 19995
Node Kind: directory
Schedule: normal
Last Changed Author: rdm
Last Changed Rev: 19824
Last Changed Date: 2007-09-19 21:46:41 +0200 (Wed, 19 Sep 2007)
Properties Last Updated: 2007-09-21 17:42:53 +0200 (Fri, 21 Sep 2007)

Synchronizing a branch with the trunk

How do I merge the latest patches added to the trunk in my development branch?

Suppose that you want to synchronize your development branch branches/mydevs with the trunk. Subversion is aware of the history of your branch and knows when it divided away from the trunk. To replicate the latest, greatest trunk changes to your branch, first make sure your working copy of the branch is “clean”—that it has no local modifications reported by svn status. Then simply run:

$ pwd
/home/user/my-oofem-branch

$ svn merge http://www.oofem.org/svn/trunk
--- Merging r345 through r356 into '.':
U    button.c
U    integer.c

This basic syntax—svn merge URL—tells Subversion to merge all recent changes from the URL to the current working directory (which is typically the root of your working copy). After running the prior example, your branch working copy now contains new local modifications, and these edits are duplications of all of the changes that have happened on the trunk since you first created your branch:

$ svn status
 M     .
M      button.c
M      integer.c

At this point, the wise thing to do is look at the changes carefully with svn diff, and then build and test your branch. Notice that the current working directory (“.”) has also been modified; the svn diff will show that its svn:mergeinfo property has been either created or modified. This is important merge-related metadata that you should not touch, since it will be needed by future svn merge commands. (We'll learn more about this metadata later in the chapter.)

After performing the merge, you might also need to resolve some conflicts (just as you do with svn update) or possibly make some small edits to get things working properly. (Remember, just because there are no syntactic conflicts doesn't mean there aren't any semantic conflicts!) If you encounter serious problems, you can always abort the local changes by running svn revert . -R (which will undo all local modifications) and start a long “what's going on?” discussion with your collaborators. If things look good, however, you can submit these changes into the repository:

$ svn commit -m "Merged latest trunk changes to my-oofem-branch."
Sending        .
Sending        button.c
Sending        integer.c
Transmitting file data ..
Committed revision 357.

At this point, your private branch is now “in sync” with the trunk, so you can rest easier knowing that as you continue to work in isolation, you're not drifting too far away from what everyone else is doing.

Displaying differences

How can I check what are the differences between my working copy of a file and revision 20474?

This is simply obtained using svn diff:

$ svn diff -r 20474 src/oofemlib/element.h
Index: src/oofemlib/element.h
===================================================================
--- src/oofemlib/element.h    (revision 20474)
+++ src/oofemlib/element.h    (working copy)
@@ -6,7 +6,7 @@
MODDIR     := xrootd
MODDIRS    := $(MODDIR)/src

 #ifdef __PARALLEL_MODE
+#ifndef __ENABLE_COMPONENT_LABELS
     globalNumber = 0;
     IR_GIVE_OPTIONAL_FIELD(ir, globalNumber, IFT_Element_globnum, "globnum"); // Macro
+#endif

Miscellaneous

What's this PREV, HEAD, etc. stuff?

Those are symbolic revision names for Subversion, just like the normal numeric ones. They mean the following:

  • HEAD: latest (youngest) revision in the server
  • BASE: the revision your checkout was last updated against
  • COMMITTED: last revision a file or directory was changed
  • PREV: the last revision the file or directory was changed immediately before COMMITTED

Maybe this is better explained with an example:

 1. You check out trunk at revision 200
 2. You make a change to trunk/a_file and commit it: revision 201 is created
 3. A day later, you update your working dir and find out it's now revision 208
 4. You make another modification and commit: revision 209
 5. One day later, you update again, this time to revision 212
 6. The following day, before updating, the server has progressed to revision 218

Under those circumstances, here's what each one of those 4 mean:

  • HEAD = 218
  • BASE = 212
  • COMMITTED (for a_file) = 209
  • PREV (for a_file) = 201

When you run “svn update”, you bring BASE up to HEAD. How to avoid seeing generated files?

How do I track changes?

There are three convenient ways to track changes:

Where to get the svn client for my machine?

Subversion is by default installed on most recent Linux distributions. On Mac OS X 10.4 you can get it from Fink or from a .dmg containing pre-built binaries. On Mac OS X 10.5 svn is part of the system. On Windows you can get it from cygwin. For all other platforms see http://subversion.tigris.org/project_packages.html.

Where to find more on Subversion?

The definite information can be found on the Subversion project page http://subversion.tigris.org/ and in the online Subversion book http://svnbook.red-bean.com/.

subversion-howto.1245320026.txt.gz · Last modified: 2009/06/18 12:13 by bp