Some pointers about the subversion (svn) tool

From Planets
Revision as of 15:36, 31 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

To know what files have been changes (with respect to your reference revision) or deleted or added in your distribution, use

svn status

which will return a list of files/directories changes. In practice each item of the list is prefixed by ? if the file is not versioned (i.e. not part of the svn repository), ! if it is missing (whereas it exists in the repository) or M if it is a modified version (i.e. you edited the file and made some changes to it, with respect to the reference)

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.

svn revert

If you have modified (or even deleted) a versioned file but want it back to its original pristine version, rather than undo the changes manually you can simply invoke:

svn revert thefileyouwantrestored

svn log

If you want to list all the revision messages (when one commits changes, one usually documents it with a short summary) use

svn log

Note that this will give you all the messages (logs) since the beginning of the repository...

If you know which revision number's log you want, you can specify it using --revision ###. e.g. to list the log for revision 666 only:

svn log --revision 666

And to list the latest log without specifying the revision number:

svn log --revision HEAD

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.