Using SVN

From Apertium
Jump to: navigation, search

En français


Apertium development code is kept in SVN. The following is a basic cheatsheet for using SVN. The SVN repository is arranged into several sub-directories:

  • trunk — this holds the main development tree for released translation pairs,
  • languages — this holds the main development tree for individual languages (depended on by translation pairs),
  • builds — holds binary releases (of packages not suited for our normal Sourceforge file releases downloads),
  • tags — this holds archived versions of releases,
  • branches — this holds branches that people are working of any of the modules in trunk,
  • incubator, nursery, staging — these hold work-in-progress modules (mostly language pairs) that have not yet made it into trunk or languages.

If you're new to Apertium and SVN, you probably just want to look at the trunk sub-directory. To browse the tree, you can just go to: raw or ViewSVN

[edit] What is SVN

SVN is a version control system. Linux and Mac users should have it installed already (otherwise, it will be available through your package manager), Windows users should use tortoisesvn (see Using SVN with TortoiseSVN).

[edit] Everyone

If you have limited bandwidth or disk space, please see Minimal installation from SVN.

To check out the whole tree:

$ svn co apertium

Note: The whole tree is over 9GB, if you're on a slow connection or have transfer limits, probably it is best to only check out the modules that you need — for a basic installation, the modules "lttoolbox" and "apertium" suffice[1].

To check out a module:

$ svn co<modulename>

So, for example, to check out the Basque-Spanish one, write

$ svn co

To perform an update:

$ svn update

[edit] Developers

To commit your changes (send them to the server):

$ svn commit

Note: Remember to write a nice log message!

To add a file or directory (to an existing module):

$ svn add <file or directory name>

To delete a file or directory from the server:

$ svn delete <file or directory name>

Note: This deletes the file locally aswell!

To import a new module into SVN:

$ svn mkdir<subrepository>/<modulename>

Then cd to the directory you want to import.

$ svn import .<subrepository>//<modulename>

[edit] Shortcuts

If you use SVN regularly, it might be worth learning some shortcuts, to save yourself some time.

Instead of svn commit you can use:

$ svn ci

Instead of svn delete, you can use

$ svn rm

If you don't want to wait for your text editor to open when you're committing, you can specify the commit message at the command line:

$ svn ci -m "My commit message"

It's worth noting here that, if you don't understand the shell fully, it's probably better to stick to the text editor.

[edit] Browsing logs and viewing diffs

Browsing SVN logs locally is slow. There's a Trac installation you can use.

[edit] Committing only part of your changes

If you have changed a number of files, and don't want to commit everything at once, you can give a list of filenames to svn commit, and only those files will be committed:

$ svn ci file1 file2

Sometimes, it's better to commit this way; to put related changes in the same commit, and keep unrelated changes separate. This makes it easier to undo your changes later, if it turns out there was a problem.

[edit] Undo local changes

If you've made changes that you don't want to keep - and you haven't committed those changes - you can use:

svn revert <file>

This will reset the files to the last version you fetched from the server.

For directories, use:

svn revert -R <directory>

[edit] Undo all or part of a commit

First work out the revision you want to rollback to (probably the revision that you just committed minus one), cd back to the apertium/ directory.

mv <modulename> <modulename>.new
svn co -r <revision><modulename>

Now copy all the files that you want to "revert" from the old revision (<modulename>) back into the new revision (<modulename>.new), then do:

rm -rf <modulename>
mv <modulename>.new <modulename>
cd <modulename>
svn commit

A faster way is to do a reverse merge, as explained in The SVN Bible. Say you want to revert the change made in revision 60101 back to the version in 60100, and restrict the revert to a certain file, do

svn merge -r 60101:60100 path/to/file

[edit] Using ssh-keys instead of passwords

Little-known secret: SVN can check out over ssh just like git :-) So you can get passwordless logins just like with regular ssh or git, without having to deal with SVN's various password storage methods.

[edit] Make a keypair

If you haven't done so already, create a keypair with


Select some passphrase for it in case someone steals your harddrive or something. If you run Ubuntu or similar it'll suggest storing it in your login keychain the first time you use it so you don't ever have to type it in again.

You'll end up with two files in ~/.ssh, named e.g. ~/.ssh/id_rsa and ~/.ssh/ The first file is your private key (encrypted with your passphrase), don't share it! The second,, is your public key, this one you should share with the servers you want to log in to.

[edit] Upload your public key to Sourceforge

Go to and paste the contents of in the field there. You may have to wait some minutes for this to get rolled out to their SVN servers.

[edit] Check out using SVN+SSH

Now you can check out your SVN module using the svn+ssh method (instead of https):

svn checkout svn+ssh://

Replace SFUSERNAME with your sourceforge username (the SFUSERNAME@ is probably optional if your sourceforge username is the same as the login to your computer).

The nice thing about this is if you use ssh (or git) a lot anyway, you can use the same key all the time, no need for remembering multiple passwords.

[edit] Free up disk space with sparse checkouts

If you've checked out the whole svn tree, and need some disk space, you can e.g. remove tags/ by cd-ing to the directory where you checked it out, then

   svn update --set-depth empty tags/

Now even if you typ "svn up", it will skip tags. To get it back, do

   svn update --set-depth infinity tags/

To check out only trunk and languages from the start, but keeping the whole SVN layout, you can do

   svn checkout --depth empty apertium-svn
   svn update --set-depth infinity apertium-svn/trunk
   svn update --set-depth infinity apertium-svn/languages

[edit] Now where did we put pair XXX-YYY?

And was it named XXX-YYY or YYY-XXX? A common modern-day frustration.

Here's a little bash function called "ca" that lets you type "ca eng tha" and be sent to incubator/apertium-tha-eng, or "ca bak" and be sent to languages/apertium-bak and so on:

(Assuming you have checked out all of apertium SVN somewhere and edited the APERTIUM_SVNROOT path in that script.)

[edit] svn up in dependent dirs as well as pair itself with one command

See the "up" script

[edit] Keeping track of new changes

You can keep track of new commits being made through

[edit] Troubleshooting

[edit] 502 Bad Gateway Errors

When executing certain operations (such as SVN COPY or branching/tagging, which use SVN COPY), you may get a 502 Bad Gateway error if you used HTTP instead of HTTPS to checkout your working copy. Relocate your working copy to HTTPS and try again. (See this ticket on the Sourceforge trac for more information. See this article for a more detailed explanation as to why this happens.)

$ svn switch --relocate

[edit] Host not found when using proxy

If you get e.g.

svn: OPTIONS of '':
	 Could not resolve hostname `': Host not found (

and are using a proxy, add


to the file ~/.subversion/servers, exchanging 3128 for the port number (3128 is the default used by Squid proxies).

SVN is picky about the format of this file. Make sure you don't have e.g. spaces in front of the lines, you'll get svn: ~/.subversion/servers:144: Option expected.

[edit] Could not authenticate to server: rejected Basic challenge

This happens because you have checked out with http and not https, you need to switch as follows:

$ svn switch --relocate
  1. (Developers) As an alternative to checking out particular modules as separate working directories consider the sparce directories feature of svn
Personal tools