Some pointers about the subversion (svn) tool

From Planets
Revision as of 10:46, 30 October 2023 by Emillour (talk | contribs)

Jump to: navigation, search

The subversion (a.k.a svn) tool

The subversion (svn) tool is what is used to keep track of the various versions of the PCM source codes. Quite similar to the also well known git tool.

Some useful svn commands

svn checkout

A checkout is simply downloading the (latest version of) reference code from the svn repository and saving a local copy. e.g. to download the entire PCM repository (i.e. "trunk" directory and sub-directories):

svn checkout https://svn.lmd.jussieu.fr/Planeto/trunk

You can add an argument to rename the directory "trunk" to whatever you want, e.g. "PCM_sources"

svn checkout https://svn.lmd.jussieu.fr/Planeto/trunk PCM_sources

Note that if you don't want to download the entire repository (likely the case if using only one of the PCMs) you can start by downloading an empty image of the "trunk":

svn checkout https://svn.lmd.jussieu.fr/Planeto/trunk --depth empty

And later use "svn update" in "trunk" to only update desired sub-directories.

It is also possible to download a given revision of the trunk with "--revision ###" (where ### is the revision number), e.g. to download revision 1567:

svn --revision 1567 checkout https://svn.lmd.jussieu.fr/Planeto/trunk

svn update

To update your working copy to the latest revision, in your "trunk" directory issue command:

svn update

Note that you can "update" to any revision number (including past ones) by specifying revision number, e.g. to update (or revert) to revision 2567:

svn update --revision 2567

svn status

svn diff

This command generates a "diff" between your local changes and local reference version, without extra arguments:

svn diff

The report will be for all files in current directory and sub-directories. One may add as a third argument the name of a given file to have only the diff concerning that file.

For experts: how to commit your changes

IMPORTANT: This only concerns you if you are included in the core team of developers with commit privileges.

  1. You must be online (committing requires to connect and interact with the svn server)
  2. You must have made you changes on (svn) versioned code, and that it is up-to-date with the repository ("svn update" is your friend).
  3. It is recommended that you have set your SVN_EDITOR environment variable to point to your favorite text editor. For instance "vi":
declare -x SVN_EDITOR=vim

Now that things are ready for the commit (you might want to check one last time with "svn diff" that all your changes are in place and that you cleaned up any intermediate stuff), you can, in the directory where you made the changes, run the command:

svn commit

Note that if you want to only commit some files and not all those you modified in the current directory and subdirectories, you can can specify explicitely the paths&names of files to commit as extra arguments to "svn commit"

Once the "svn commit" command launched, your editor will open up, pre-filled with the differences in the code implied by your changes automatically inserted. All you need to do is fill in the first part of the message with comments about your changes (e.g. bug fix of ... , added feature as ..., code tidying, etc.). usually a few lines suffice. It is common practice to state in the first line of the commit which PCM is concerned ("Mars PCM", "Generic PCM", "Venus PCM", ...) and to sign the commit with your initials. Once you have entered your message, just save the file and this will automatically trigger the commit.

Once the commit triggered, you will need to specify you svn account login and password, at least the first time (svn can save and store these so that you don't need to enter them every time).

Some typical svn errors you may run into

If when trying t use an svn command you get a message of the likes of:

svn: E155036: The working copy at ....
is too old (format 29) to work with client version '1.10.2 (r1835932)' (expects format 31). You need to upgrade the working copy first.

This simply means that your svn tool has been upgraded to a more recent version and that you need to upgrade your current repository to follow up. In order to do that simply do

svn upgrade

And then you can keep using svn as before.