<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://source.geography.bristol.ac.uk/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jprenaud</id>
	<title>SourceWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://source.geography.bristol.ac.uk/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jprenaud"/>
	<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/wiki/Special:Contributions/Jprenaud"/>
	<updated>2026-04-07T00:25:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.8</generator>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5655</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5655"/>
		<updated>2008-09-19T09:57:01Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Environment set-up */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
The current modules are:&lt;br /&gt;
* TELEMAC-2D, 2D flood inundation&lt;br /&gt;
* SISYPHE, 2D river bed evolution&lt;br /&gt;
* ESTEL-2D, 2D groundwater flow and contaminant transport&lt;br /&gt;
* ESTEL-3D. 3D groundwater flow and contaminant transport&lt;br /&gt;
More modules (3D hydrodynamics, waves ...) could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environment for editing files etc... See [[General_use_of_the_TELEMAC_system#A_note_about_ASCII_files | note below]] for a word of warning about MS Windows text editors.&amp;quot; [[User:Jprenaud|JP Renaud]] 18:25, 18 September 2008 (BST)&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. This is normal, the location probably does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. For instance, you could use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
# Only done on dylan&lt;br /&gt;
if [ `hostname | grep dylan` ]; then&lt;br /&gt;
    SYSTEL90=/home/telemac&lt;br /&gt;
    export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
    source $SYSTEL90/intel_env&lt;br /&gt;
    source $SYSTEL90/config/systel_env&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5654</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5654"/>
		<updated>2008-09-19T09:55:57Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
The current modules are:&lt;br /&gt;
* TELEMAC-2D, 2D flood inundation&lt;br /&gt;
* SISYPHE, 2D river bed evolution&lt;br /&gt;
* ESTEL-2D, 2D groundwater flow and contaminant transport&lt;br /&gt;
* ESTEL-3D. 3D groundwater flow and contaminant transport&lt;br /&gt;
More modules (3D hydrodynamics, waves ...) could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environment for editing files etc... See [[General_use_of_the_TELEMAC_system#A_note_about_ASCII_files | note below]] for a word of warning about MS Windows text editors.&amp;quot; [[User:Jprenaud|JP Renaud]] 18:25, 18 September 2008 (BST)&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. This is normal, the location probably does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. For instance, you could use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
# Only done on dylan&lt;br /&gt;
if [ `hostname` | grep dylan ]; then&lt;br /&gt;
    SYSTEL90=/home/telemac&lt;br /&gt;
    export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
    source $SYSTEL90/intel_env&lt;br /&gt;
    source $SYSTEL90/config/systel_env&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5653</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5653"/>
		<updated>2008-09-18T17:37:16Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
The current modules are:&lt;br /&gt;
- TELEMAC-2D, 2D flood inundation&lt;br /&gt;
- SISYPHE, 2D river bed evolution&lt;br /&gt;
- ESTEL-2D, 2D groundwater flow and contaminant transport&lt;br /&gt;
- ESTEL-3D. 3D groundwater flow and contaminant transport&lt;br /&gt;
More modules (3D hydrodynamics, waves ...) could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environment for editing files etc... See [[General_use_of_the_TELEMAC_system#A_note_about_ASCII_files | note below]] for a word of warning about MS Windows text editors.&amp;quot; [[User:Jprenaud|JP Renaud]] 18:25, 18 September 2008 (BST)&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. This is normal, the location probably does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan.&lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5652</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5652"/>
		<updated>2008-09-18T17:26:19Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Environment set-up */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environment for editing files etc... See [[General_use_of_the_TELEMAC_system#A_note_about_ASCII_files | note below]] for a word of warning about MS Windows text editors.&amp;quot; [[User:Jprenaud|JP Renaud]] 18:25, 18 September 2008 (BST)&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. This is normal, the location probably does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan.&lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5651</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5651"/>
		<updated>2008-09-18T17:25:31Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environment for editing files etc... See [[General_use_of_the_TELEMAC_system#A_note_about_ASCII_files | note below]] for a word of warning about MS Windows text editors.&amp;quot; [[User:Jprenaud|JP Renaud]] 18:25, 18 September 2008 (BST)&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5650</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5650"/>
		<updated>2008-09-18T17:25:06Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environemtn for editing files etc... See [[General_use_of_the_TELEMAC_system#A_note_about_ASCII_files | note below]] for a word of warning about MS Windows text editors.&amp;quot; [[User:Jprenaud|JP Renaud]] 18:25, 18 September 2008 (BST)&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5649</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5649"/>
		<updated>2008-09-18T17:24:32Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environemtn for editing files etc... See [[General_use_of_the_TELEMAC_system#A_note_about_ASCII_files | note below]] for a word of warning about MS Windows text editors.&amp;quot;[[User:Jprenaud|JP]]&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5648</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5648"/>
		<updated>2008-09-18T17:24:13Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environemtn for editing files etc... See [[General_use_of_the_TELEMAC_system#A_note_about_ASCII_files | note below]] for a word of warning about MS Windows text editors.&amp;quot; 18:23, 18 September 2008 (BST)&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5647</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5647"/>
		<updated>2008-09-18T17:23:45Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Note that because the pre- and post-prtocessors run on MS Windows, I personally encourage people to use the Linux shell only to start the TELEMAC jobs and use the MS Windows environemtn for editing files etc... See [[note below]] for a word of warning about MS Windows text editors.&amp;quot; 18:23, 18 September 2008 (BST)&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5646</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5646"/>
		<updated>2008-09-18T17:21:13Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII files =&lt;br /&gt;
&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;br /&gt;
&lt;br /&gt;
=Changing between versions of the TELEMAC system=&lt;br /&gt;
The basic configuration allows the user to switch transparently between versions of the TELEMAC system via the commands v5p8 and v5p9:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ v5p9&lt;br /&gt;
Switched to TELEMAC version: v5p9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Version v5p9 is under development and you are encouraged not to use it though! It might be that a developer asks you to test something under version v5p9 so this is merely to make this easier.&lt;br /&gt;
&lt;br /&gt;
=A note about binary files=&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5645</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5645"/>
		<updated>2008-09-18T17:17:52Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* A note about ascii and binary files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ASCII and binary files =&lt;br /&gt;
&lt;br /&gt;
==ASCII files==&lt;br /&gt;
Windows and Linux treat end of line in ASCII files differently. This means that if you edit a steering file on Windows using MS Notepad, you might have problems running the simulation on Linux. However, it is sometimes cumbersome to use text editors on Linux via an ssh session. The solution is too use a good text editor and configure it to use Unix type end of line characters. [http://www.scintilla.org/SciTE.html Scite] is a very good text editor for the MS Windows environment.&lt;br /&gt;
&lt;br /&gt;
==Binary files==&lt;br /&gt;
TELEMAC was traditionally run on large Unix machines which have a different way of storing binary data than the PCs used today. They are called &amp;quot;big endian&amp;quot; systems and most PCs are &amp;quot;little endian&amp;quot; machines. By convention, TELEMAC uses files in the big endian format. Luckily, the pre- and post-processors running on the PCs can output or read big endian.&lt;br /&gt;
&lt;br /&gt;
In terms of the TELEMAC code itself, the Intel compiler is very handy as the big or little endian type can be changed without having to recompile the whole code. This is done with the environmental variable F_UFMTENDIAN. It defaults at &amp;quot;big&amp;quot; (see /home/telemac/intel_env). This can be changed for particular applications but really you should not have to do anything.&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5644</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5644"/>
		<updated>2008-09-18T17:07:27Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Parallel jobs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ascii and binary files =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite using different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is also possible to run TELEMAC on the University cluster, bluecrystal. This is described on another page (not finished yet but will be done soon).&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5643</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5643"/>
		<updated>2008-09-18T17:06:12Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Parallel jobs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ascii and binary files =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 cores so the system is configured to run with '''8 processors as a maximum'''.&lt;br /&gt;
&lt;br /&gt;
Put &amp;quot;0&amp;quot; to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should give the same results despite two different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. Note that this needs to be done once per login, not for each job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster this time, maybe 30 seconds or so instead of 55 seconds. It is not a lot faster (certainly not 8 times faster!) but this is because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time. With biggers meshes and longer sinmulations, you should get a better acceleration.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5642</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5642"/>
		<updated>2008-09-18T16:55:26Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Linux =&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot; which the Linux operating system (CentOS).&lt;br /&gt;
'''You will need to log into dylan and use linux commands to run TELEMAC jobs'''. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this. Ask the scientific computer officer for pointers if you need some and get some training if required.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you log in another machine (i.e. not dylan) you might get an error message about &amp;quot;/home/telemac&amp;quot; not existing or file not found. this is normal. It does not exist of the other machine... Live with it or adapt the .bashrc so that the files are sourced only on dylan. &lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-2d includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured environment. Now go and do some real work with your own files&lt;br /&gt;
&lt;br /&gt;
= A note about ascii and binary files =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. However, a few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number of processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that dylan has 8 processor cores so the system is configured to run with '''8 processors as a maximum'''. Put 0 to run in scalar mode. &amp;quot;1&amp;quot; runs in parallel mode but with one processor only, so &amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; should gibve the ssame results despite two different libraries.&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. This needs to be done once per login.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run teleun telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster, maybe 30 seconds or so. It is not a lot faster because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5641</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5641"/>
		<updated>2008-09-18T16:47:55Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Environment set-up */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot;. You will need to log into dylan to run TELEMAC jobs. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-ed includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured enviroment. Now go and do some real work...&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. A few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number odf processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. This needs to be done once per login.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run teleun telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster, maybe 30 seconds or so. It is not a lot faster because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5640</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5640"/>
		<updated>2008-09-18T16:47:40Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Environment set-up */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot;. You will need to log into dylan to run TELEMAC jobs. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ which telemac2d&lt;br /&gt;
/home/telemac/bin/telemac2d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-ed includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured enviroment. Now go and do some real work...&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. A few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number odf processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. This needs to be done once per login.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run teleun telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster, maybe 30 seconds or so. It is not a lot faster because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5639</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5639"/>
		<updated>2008-09-18T16:46:38Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot;. You will need to log into dylan to run TELEMAC jobs. Therefore it helps to practice a bit in a Linux environment. The [[:category:Pragmatic Programming | Pragmatic Programming]] course might be a good place for this.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
It is very easy to configure the environment to use TELEMAC as you simply have to source central files. Simply add the following lines into your .bashrc configuration file, then log-out and back in again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then be able to &amp;quot;see&amp;quot; the Fortran compiler and the programs of the TELEMAC system.&lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
Telemac-ed includes some test cases. Copy one into your filespace and run it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this works, you have a well configured enviroment. Now go and do some real work...&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is configured to run in parallel mode if requested by the user. This is actually a very simple thing to do and highly encouraged if you use large meshes and run long simulations. A few extra initial steps are required.&lt;br /&gt;
&lt;br /&gt;
TELEMAC uses MPI for parallel operations. MPI requires a secret word in a hidden configuration file. Simply type the following instructions to create it. Note that &amp;quot;somethingsecret&amp;quot; below should contains no spaces. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ touch .mpd.conf&lt;br /&gt;
$ chmod 600 .mpd.conf&lt;br /&gt;
$ echo &amp;quot;MPD_SECRETWORD=somethingsecret &amp;quot; &amp;gt; .mpd.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode once to look at job duration, for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
$ cd cavity/&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above should run in about 55s on dylan. Now edit cas.txt so that the line about the number odf processors looks like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PARALLEL PROCESSORS = 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before you can run TELEMAC in parallel, you need to start the MPI daemon. This needs to be done once per login.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can now run teleun telemac2d again:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should run again, faster, maybe 30 seconds or so. It is not a lot faster because it's a silly example and splitting the mesh in 8 subdomains accounts for a large part of the computation time.&lt;br /&gt;
&lt;br /&gt;
Before you log out, it is a good idea to kill the MPI daemon:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5638</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5638"/>
		<updated>2008-09-18T16:22:34Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
&lt;br /&gt;
This page describes the general use of the TELEMAC system in Geographical Sciences.&lt;br /&gt;
&lt;br /&gt;
The TELEMAC system is installed centrally on &amp;quot;dylan&amp;quot;. You will need to log into dylan to run TELEMAC jobs. Therefore it helps to practice a bit in a Linux environment. The [Category:Pragmatic_Programming] course can be useful.&lt;br /&gt;
&lt;br /&gt;
TELEMAC-2D, SISYPHE, ESTEL-2D and ESTEL-3D are available. More modules could be added if necessary. Just ask.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Test = &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/hydraulic_jump .&lt;br /&gt;
$ cd hydraulic_jump&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;br /&gt;
The TELEMAC is automatically configured to run in parallel mode. To run &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd $HOME&lt;br /&gt;
  touch .mpd.conf&lt;br /&gt;
  chmod 600 .mpd.conf&lt;br /&gt;
  MPD_SECRETWORD=&amp;quot;somethingsecret&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the software once in scalar mode&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp -r /home/telemac/telemac2d/tel2d_v5p8/test.gb/cavity .&lt;br /&gt;
[ggjpr@dylan ~]$ cd cavity/&lt;br /&gt;
[ggjpr@dylan confluence]$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Should run in about 55s&lt;br /&gt;
Edit cas.txt and run telemac2d again and&lt;br /&gt;
Start the ring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpd &amp;amp;&lt;br /&gt;
$ telemac2d cas.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 it should run again, faster, maybe 30s inclu&lt;br /&gt;
&lt;br /&gt;
when you log out, it is a good idea to kill the MPI daemon with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mpdallexit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5637</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5637"/>
		<updated>2008-09-18T16:03:08Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* dylan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
This page&lt;br /&gt;
&lt;br /&gt;
= dylan =&lt;br /&gt;
The TELEMAC system is installed centrally on dylan. TELEMAC-2D, ESTEL-2D and ESTEL-3D are available.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
TELEMAC system:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that with the above configuration&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5636</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5636"/>
		<updated>2008-09-18T16:01:26Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Environment set-up */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
This page&lt;br /&gt;
&lt;br /&gt;
= dylan =&lt;br /&gt;
The TELEMAC system is installed centrally on dylan.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
TELEMAC system:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Location of the TELEMAC system&lt;br /&gt;
SYSTEL90=/home/telemac&lt;br /&gt;
export SYSTEL90&lt;br /&gt;
&lt;br /&gt;
source $SYSTEL90/intel_env&lt;br /&gt;
source $SYSTEL90/config/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that with the above configuration&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5635</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5635"/>
		<updated>2008-09-18T15:12:48Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
This page&lt;br /&gt;
&lt;br /&gt;
= dylan =&lt;br /&gt;
The TELEMAC system is installed centrally on dylan.&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
TELEMAC system:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source /home/telemac/configv5p8/systel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Intel Fortran90 compiler&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source /home/telemac/intel_env&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that with the above configuration&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5634</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5634"/>
		<updated>2008-09-18T10:06:25Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Estel]]&lt;br /&gt;
[[Category:Telemac]]&lt;br /&gt;
This page&lt;br /&gt;
&lt;br /&gt;
= dylan =&lt;br /&gt;
&lt;br /&gt;
= Environment set-up =&lt;br /&gt;
&lt;br /&gt;
= Parallel jobs =&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5633</id>
		<title>General use of the TELEMAC system</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=General_use_of_the_TELEMAC_system&amp;diff=5633"/>
		<updated>2008-09-18T10:01:12Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Blah&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Estel&amp;diff=5632</id>
		<title>Estel</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Estel&amp;diff=5632"/>
		<updated>2008-09-18T10:00:54Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Projects]]&lt;br /&gt;
[[Category:Estel]]&lt;br /&gt;
&lt;br /&gt;
This wiki contains information for both the users and developers of TELEMAC and [http://www.ggy.bris.ac.uk/research/hydrology/models/estel ESTEL].&lt;br /&gt;
&lt;br /&gt;
Please contribute, update and create new pages if you cannot find the information that you need. It will certainly help other people. And remember, if you write it on the wiki and not only on a bit of paper, it won't get lost!!!&lt;br /&gt;
&lt;br /&gt;
=User documentation=&lt;br /&gt;
All open-access documentation about TELEMAC and ESTEL can be accessed from here.&lt;br /&gt;
&lt;br /&gt;
* Installation:&lt;br /&gt;
** [[Install the TELEMAC system ]]&lt;br /&gt;
** [[Update the TELEMAC system]]&lt;br /&gt;
* [[General use of the TELEMAC system]]&lt;br /&gt;
* The [[Official ESTEL Documentation]] page&lt;br /&gt;
* Tips and tricks:&lt;br /&gt;
&amp;lt;!---** [[ ESTEL-2D How To page]] ---&amp;gt;&lt;br /&gt;
&amp;lt;!---** [[ ESTEL-3D How To page]] ---&amp;gt;&lt;br /&gt;
** [[ Handy Tecplot Add-ons]]&lt;br /&gt;
** [[ Examples of compiler sections in systel.ini ]]&lt;br /&gt;
** [[ How to swap between versions of the TELEMAC system ]]&lt;br /&gt;
** [[ How to run ESTEL in parallel ]] (network of workstations)&lt;br /&gt;
** [[ How to run ESTEL in parallel on a cluster]] (high performance cluster)&lt;br /&gt;
&lt;br /&gt;
=Developer documentation=&lt;br /&gt;
To access the [[ ESTEL:Developer_documentation | developer documentation]], you need to be registered as an '''ESTEL''' developer for this wiki. Contact [[User:Jprenaud|JP Renaud]] if you need access to this section.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Polyglot&amp;diff=5242</id>
		<title>Polyglot</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Polyglot&amp;diff=5242"/>
		<updated>2008-05-29T09:51:15Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
'''Mixed Language Programming:  Mix up a quick and useful cocktail today!'''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
One of the key underling themes in this series of ''pragmatic programming'' workshops is getting things done, with a minimum of fuss and wasted effort, and this workshop on '''mixed language programming''' is no exception.&lt;br /&gt;
&lt;br /&gt;
When we sit down to a keyboard, we do so with a particular goal in mind.  We have a task, idea or experiment and the computer is our workbench.  The languages we write programes with, along with the text editors, compilers, debuggers etc. are our tools.  Now some tools are better than others (e.g. Subversion is an improvment upon CVS).  Some we just may have a preference for (e.g. emacs vs. vi for editing files).  None are perfect, however, and all have their pros and cons.      &lt;br /&gt;
&lt;br /&gt;
What's all this got to do with mixed language programming? you ask.  Well, imagine a scenario:&lt;br /&gt;
&lt;br /&gt;
You sit down to your workbench.  You have your goal and you ask yourself whether somebody else has written some code which will do at least part of what you want.  Perhaps they've bundled it up into a nice open-source library that you can use?  That way you'll save truck-loads of time.  A couple of web searches later, and bingo!  You've found an ideal library for the job.  There's only one snag.  You like programming in Fortran, and the library is written in C.  Scuppered!  Well, perhaps not..&lt;br /&gt;
&lt;br /&gt;
What are your options?  You could use something not so suitable because it happens to be written in Fortran.  Hmm, that doesn't sound so good.  You could translate the library from C to Fortran.  Hmm, that sounds like tedious and time-consuming work.  Plus you'd need to understand the C, and perhaps a direct translation can't be made anyhow?  This is looking like a dead-end too.  It would be far better to leave the library as it is and to call the routines from your favoured language.  Is that possible?  Sure it is!  Read on and find out how..&lt;br /&gt;
&lt;br /&gt;
In this workshop, we'll look at ways in which we can mix languages and in the process create a useful end product which plays to the strengths of it's components and gets you to where you want to be, without any laborious re-writes.  In the first two examples we'll look at calling C code from Fortran and then calling Fortran from C.  To get the code for examples, log into your preferred Linux machine and cut and paste the following into your terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn export http://source.ggy.bris.ac.uk/subversion-open/polyglot/trunk ./polyglot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Making a Fortran wrapped C parcel =&lt;br /&gt;
&lt;br /&gt;
In the first example we'll call a C function from a Fortran program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd examples/example1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To compile the example, type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and to run it, type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
call_c.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tada!  We've mixed our languages into a single executable and it works!  Cool.  Very cool.  OK, so much for the magic, let's take a look inside the files.  Open up '''call_c.f90'''.  In this simple program, we have a character string that we pass to the C function--called '''cfunc'''--which in turn modifies the string and we can print the result.  For those familiar with Fotran90, the main program is trivial enough.  So, let's turn to the C code in '''func.c'''.  Again this is a simple function and the syntax will be familiar to those who know some C.  An interesting detail, however, is the name of the function.  Note that we have called it '''cfunc_''', i.e. with a trailing underscore.  Why on earth have we done that?  Well, we are anticipating the 'decoration' or '''name mangling''' that the compiler will apply.&lt;br /&gt;
&lt;br /&gt;
We can look inside the object files using a utility called '''nm'''.  First let's look inside '''call_c.o'''.  On my machine I get:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; nm call_c.o&lt;br /&gt;
00000000 T MAIN__&lt;br /&gt;
         U _gfortran_set_std&lt;br /&gt;
         U _gfortran_st_write&lt;br /&gt;
         U _gfortran_st_write_done&lt;br /&gt;
         U _gfortran_transfer_character&lt;br /&gt;
         U cfunc_&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are the '''symbols''' created by the compiler in the object file.  Now let's look inside '''func.o''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;  nm func.o&lt;br /&gt;
00000000 T cfunc_&lt;br /&gt;
&amp;lt;/pre&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Note the two '''cfunc_'''s?  '''They match!'''  If we had not pre-decorated the name of the function in '''func.c''', we would not have got a match and we would have got a link-time error.  However, we were smart and got ourselves a working executable--hurrah!&lt;br /&gt;
&lt;br /&gt;
A word of caution, however.  Different compilers 'mangle' subroutine and function names differently, i.e. dependening upon the mix of compilers, we can't always rely on a single trailing underscore decoration.  You will need to use '''nm''' to determine the exact decoration your Fortran compiler expects and to design your code so that any changes are easily accomodated.  One way to do this is to include a '''define''' preprocessor macro in you C code, such as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define CFUNC cfunc_&lt;br /&gt;
...&lt;br /&gt;
void CFUNC(int* string_size, char* string)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In that way, a change of decoration can be easily, and consistently made across the whole file/library.&lt;br /&gt;
&lt;br /&gt;
= Turning the Parcel Inside-Out =&lt;br /&gt;
&lt;br /&gt;
OK let's turn our mind to working the other way 'round and call a Fortran subroutine from a C program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ../example2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can compile and run in a similar way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
./call_fort.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you look inside the two key files, '''sub.f90''' and '''call_fort.c''', you can see that we've still kept the program fairly simple, but we've introduced a few more variable types (integers, floating-point numbers and arrays) and syntactic refinements (use of preprocessor macros and 'const' and 'intent(in)' declarations).&lt;br /&gt;
&lt;br /&gt;
The decoration and name-mangling will be familiar to you from the last example.  Note the use of the '''define''' macro in '''call_fort.c''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#define FORT_SUB fort_sub_&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code comments in the last example touched upon the distinction between the '''pass-by-value''' default behaviour of C and the '''pass-by-reference''' adopted by Fortran.  Thus, in order to dovetail the two languages, we must prevail upon our C code to use pass-by-reference.  We can see this in the function prototype in '''call_fort.c''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
extern void FORT_SUB(const int*, const int*, float[]);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we are declaring that we will use '''pointers-to''' variables, i.e. addresseses or '''references''', as the arguments to the routine, denoted by the '''*'''s.  The routine, of course, is written in Fortran, and so is expecting these references.  By default, C would have taken a '''copy''' of the '''value''' of a variable and passed that.  This is where the term '''pass-by-value''' comes from.  (Note that a side effect of pass-by-value is that any changes are only local to a routine and so do not have an effect on the value of the variable used in the calling routine.)  Note the the '''const''' modifiers match with the '''intent(in)''' attributes in '''sub.f90'''.  This is an example of defensive programming.  Normally, when we pass references, we run the risk that called routine could modify the values of the variables in a lasting way.  This may not be what you would like, and so it would be '''unsafe'''.  However, by using '''const''' and '''intent(in)''', we are saying from both sides that some values are not to be changed and so we protect ourselves.&lt;br /&gt;
&lt;br /&gt;
In general with mixed langauge programming, we need to be careful about mathing the variable types we pass between the languages.  For example, C typically uses 4 bytes to store a '''float'''.  However, Fortran may use 4 or 8 bytes to store a '''real''', depending upon the type of processor in the machine (32 ior 64 bit).  We need to be careful to ensure a match, otherwise we could have all sorts errors in store realated to truncation or uninitialsed memory space.  Thus in '''sub.f90''', we have limited our variables to 4 bytes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer(kind=4),intent(in)                     :: arg_in&lt;br /&gt;
  integer(kind=4),intent(in)                     :: array_size&lt;br /&gt;
  real(kind=4),dimension(array_size),intent(out) :: arg_out&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An intersting point of difference to note between Fortran and C is that arrays are indexed differently.  Firstly, Fortran gives the first element of an array the index 1, by default.  C gives it an index of 0.  Compare the two loops in the source code files.  First for the calling C program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  /* initialise array to ones */&lt;br /&gt;
  for(ii=0;ii&amp;lt;MAXSIZE;++ii) {&lt;br /&gt;
    from_fort[ii] = 1.0;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
and second for the Fortran subroutine:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ! just set output to be equal to input&lt;br /&gt;
  do ii=1,array_size&lt;br /&gt;
     arg_out(ii) = real(arg_in)&lt;br /&gt;
  end do&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Things diverge further for multi-dimensional arrays.  This is because arrays in C are 'row-major' and arrays in Fortran are 'column major' in their ordering.  Thus for a defualt 2-dimensional array, the cell (3,7) in C would map to (8,4) in Fortran.  Oh the joys of mixed languages!  Thankfully, since program units are typically self-contained and we would pass arrays in their entirity (actually just the memory address of the first cell), this difference in behaviour does not cause many headaches.&lt;br /&gt;
&lt;br /&gt;
= The cfortran Header File Project =&lt;br /&gt;
&lt;br /&gt;
* [http://www-zeus.desy.de/~burow/cfortran/cfortran.html]&lt;br /&gt;
&lt;br /&gt;
= Calling C from Python using SWIG =&lt;br /&gt;
&lt;br /&gt;
'''NB You will need &amp;lt;code&amp;gt;swig&amp;lt;/code&amp;gt; installed on your machine for this example. &amp;lt;code&amp;gt;swig&amp;lt;/code&amp;gt; is instaled on dylan'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ../example4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./test.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently as per:&lt;br /&gt;
* [http://www.swig.org/tutorial.html]&lt;br /&gt;
&lt;br /&gt;
Here we move from 'mixing', to more of an API arrangement.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5205</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5205"/>
		<updated>2008-05-15T15:07:14Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: every time something is changed in the repository, the server logs the '''time and date''', the '''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get information about your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called &amp;quot;subversion&amp;quot; and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by navigating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn]. Select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
(If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.)&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
Note that &amp;quot;trunk/&amp;quot; at the end of the URL is just a convention. Usually, subversion repositories are organised so that the latest version is in the &amp;quot;trunk/&amp;quot; and other versions are in &amp;quot;branches/&amp;quot;. This is purely semantics, as far as subversion is concerned, &amp;quot;trunk&amp;quot; and &amp;quot;branches&amp;quot; are merely two folders under URL.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some commands can also use options which are given with dashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is yours to work with so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conflicts=&lt;br /&gt;
&lt;br /&gt;
Sometimes, a commit or an update will fail because of conflicting changes. As a rule, you should always update before a commit so the example here will show a conflict creating after an update. &lt;br /&gt;
&lt;br /&gt;
==Creating the conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modifies file1 by adding a line and commits (let's assume revision5)&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits (revision 6)&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
The update does not fail but file1 is flagged with the letter &amp;quot;C&amp;quot; indicating a conflict and you will notice new files in your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$svn status&lt;br /&gt;
?      file1.r5&lt;br /&gt;
?      file1.r6&lt;br /&gt;
?      file1.mine&lt;br /&gt;
C      file1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* file1.r5 is file1 as at revision 5 (i.e. the one at your last update)&lt;br /&gt;
* file1.r6 is file1 at revision 6 (i.e. the one that is on the repository now)&lt;br /&gt;
* file1.mine is file1 as it was in working copy before the update&lt;br /&gt;
* file1 contains an attempt at merging the changes&lt;br /&gt;
&lt;br /&gt;
==Resolving the conflict==&lt;br /&gt;
&lt;br /&gt;
Let's look at file1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat file1&lt;br /&gt;
Added this line.&lt;br /&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; .mine&lt;br /&gt;
This will create the conflict.&lt;br /&gt;
=======&lt;br /&gt;
This LINE will create the conflict.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; .r6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Subversion uses &amp;quot;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;quot; and &amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;quot; to show the problem(s). Your version of the problem lines is shown first (.mine) and then the version in the repository (.r6).&lt;br /&gt;
&lt;br /&gt;
To solve the conflict, you need to edit this file and mark it as solved. For instance, let's assume that your version was the good one (that's probably not a good assumption in normal development cycles as you are just ignoring one commit here). To resolve the conflict, one could do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp file1.mine file1&lt;br /&gt;
$ svn resolved file1&lt;br /&gt;
Resolved conflicted state of 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the extra file disappear when the initial file is marked as &amp;quot;resolved&amp;quot;. Now you could commit your changes. But '''don't''' during the practical as all of you have resolved the conflict at the same time and this should be done only once.&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir and cp ==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then you might want to create a branch of your project, for instance to call it &amp;quot;version1&amp;quot; as you start to work on version2. branching is merely a copy so you can do it directly on the server also:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn cp -r URL/trunk URL/branches/version1 --message &amp;quot;Creation of the version1 branch.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you could check out URL/branches/version1 to work on version1 rather than the trunk.&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
The [http://svnbook.red-bean.com/ Subversion Red Book] is the bible of subversion. Very recommended.&lt;br /&gt;
&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the &amp;quot;Pragmatic Programming&amp;quot; course was useful and that you feel (at least a bit) more confident about coding on the Linux platform. Have fun.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5203</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5203"/>
		<updated>2008-05-15T15:04:53Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: every time something is changed in the repository, the server logs the '''time and date''', the '''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get information about your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called &amp;quot;subversion&amp;quot; and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by navigating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;trunk/&amp;quot; at the end of the URL is just a convention. Usually, subversion repositories are organised so that the latest version is in the &amp;quot;trunk/&amp;quot; and other versions are in &amp;quot;branches/&amp;quot;. This is purely semantics, as far as subversion is concerned, &amp;quot;trunk&amp;quot; and &amp;quot;branches&amp;quot; are merely two folders under URL.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some commands can also use options which are given with dashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is yours to work with so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conflicts=&lt;br /&gt;
&lt;br /&gt;
Sometimes, a commit or an update will fail because of conflicting changes. As a rule, you should always update before a commit so the example here will show a conflict creating after an update. &lt;br /&gt;
&lt;br /&gt;
==Creating the conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modifies file1 by adding a line and commits (let's assume revision5)&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits (revision 6)&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
The update does not fail but file1 is flagged with the letter &amp;quot;C&amp;quot; indicating a conflict and you will notice new files in your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$svn status&lt;br /&gt;
?      file1.r5&lt;br /&gt;
?      file1.r6&lt;br /&gt;
?      file1.mine&lt;br /&gt;
C      file1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* file1.r5 is file1 as at revision 5 (i.e. the one at your last update)&lt;br /&gt;
* file1.r6 is file1 at revision 6 (i.e. the one that is on the repository now)&lt;br /&gt;
* file1.mine is file1 as it was in working copy before the update&lt;br /&gt;
* file1 contains an attempt at merging the changes&lt;br /&gt;
&lt;br /&gt;
==Resolving the conflict==&lt;br /&gt;
&lt;br /&gt;
Let's look at file1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat file1&lt;br /&gt;
Added this line.&lt;br /&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; .mine&lt;br /&gt;
This will create the conflict.&lt;br /&gt;
=======&lt;br /&gt;
This LINE will create the conflict.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; .r6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Subversion uses &amp;quot;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;quot; and &amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;quot; to show the problem(s). Your version of the problem lines is shown first (.mine) and then the version in the repository (.r6).&lt;br /&gt;
&lt;br /&gt;
To solve the conflict, you need to edit this file and mark it as solved. For instance, let's assume that your version was the good one (that's probably not a good assumption in normal development cycles as you are just ignoring one commit here). To resolve the conflict, one could do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp file1.mine file1&lt;br /&gt;
$ svn resolved file1&lt;br /&gt;
Resolved conflicted state of 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the extra file disappear when the initial file is marked as &amp;quot;resolved&amp;quot;. Now you could commit your changes. But '''don't''' during the practical as all of you have resolved the conflict at the same time and this should be done only once.&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir and cp ==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then you might want to create a branch of your project, for instance to call it &amp;quot;version1&amp;quot; as you start to work on version2. branching is merely a copy so you can do it directly on the server also:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn cp -r URL/trunk URL/branches/version1 --message &amp;quot;Creation of the version1 branch.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you could check out URL/branches/version1 to work on version1 rather than the trunk.&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
The [http://svnbook.red-bean.com/ Subversion Red Book] is the bible of subversion. Very recommended.&lt;br /&gt;
&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the &amp;quot;Pragmatic Programming&amp;quot; course was useful and that you feel (at least a bit) more confident about coding on the Linux platform. Have fun.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5202</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5202"/>
		<updated>2008-05-15T15:02:49Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: every time something is changed in the repository, the server logs the '''time and date''', the '''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get information about your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called &amp;quot;subversion&amp;quot; and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by navigating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;trunk/&amp;quot; at the end of the URL is just a convention. Usually, subversion repositories are organised so that the latest version is in the &amp;quot;trunk/&amp;quot; and other versions are in &amp;quot;branches/&amp;quot;. This is purely semantics, as far as subversion is concerned, &amp;quot;trunk&amp;quot; and &amp;quot;branches&amp;quot; are merely two folders under URL.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some commands can also use options which are given with dashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is yours to work with so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Conflicts=&lt;br /&gt;
&lt;br /&gt;
Sometimes, a commit or an update will fail because of conflicting changes. As a rule, you should always update before a commit so the example here will show a conflict creating after an update. &lt;br /&gt;
&lt;br /&gt;
==Creating the conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modifies file1 by adding a line and commits (let's assume revision5)&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits (revision 6)&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
The update does not fail but file1 is flagged with the letter &amp;quot;C&amp;quot; indicating a conflict and you will notice new files in your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$svn status&lt;br /&gt;
?      file1.r5&lt;br /&gt;
?      file1.r6&lt;br /&gt;
?      file1.mine&lt;br /&gt;
C      file1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* file1.r5 is file1 as at revision 5 (i.e. the one at your last update)&lt;br /&gt;
* file1.r6 is file1 at revision 6 (i.e. the one that is on the repository now)&lt;br /&gt;
* file1.mine is file1 as it was in working copy before the update&lt;br /&gt;
* file1 contains an attempt at merging the changes&lt;br /&gt;
&lt;br /&gt;
Let's look at file1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat file1&lt;br /&gt;
Added this line.&lt;br /&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; .mine&lt;br /&gt;
This will create the conflict.&lt;br /&gt;
=======&lt;br /&gt;
This LINE will create the conflict.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; .r6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Subversion uses &amp;quot;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;quot; and &amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;quot; to show the problem(s). Your version of the problem lines is shown first (.mine) and then the version in the repository (.r6).&lt;br /&gt;
&lt;br /&gt;
To solve the conflict, you need to edit this file and mark it as solved. For instance, let's assume that your version was the good one (that's probably not a good assumption in normal development cycles as you are just ignoring one commit here). To resolve the conflict, one could do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp file1.mine file1&lt;br /&gt;
$ svn resolved file1&lt;br /&gt;
Resolved conflicted state of 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you could commit your changes. But '''don't''' during the practical as all of you have resolved the conflict at the same time and this should be done only once.&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir and cp ==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then you might want to create a branch of your project, for instance to call it &amp;quot;version1&amp;quot; as you start to work on version2. branching is merely a copy so you can do it directly on the server also:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn cp -r URL/trunk URL/branches/version1 --message &amp;quot;Creation of the version1 branch.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you could check out URL/branches/version1 to work on version1 rather than the trunk.&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
The [http://svnbook.red-bean.com/ Subversion Red Book] is the bible of subversion. Very recommended.&lt;br /&gt;
&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the &amp;quot;Pragmatic Programming&amp;quot; course was useful and that you feel (at least a bit) more confident about coding on the Linux platform. Have fun.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5201</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5201"/>
		<updated>2008-05-15T14:55:29Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: every time something is changed in the repository, the server logs the '''time and date''', the '''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get information about your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called &amp;quot;subversion&amp;quot; and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by navigating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;trunk/&amp;quot; at the end of the URL is just a convention. Usually, subversion repositories are organised so that the latest version is in the &amp;quot;trunk/&amp;quot; and other versions are in &amp;quot;branches/&amp;quot;. This is purely semantics, as far as subversion is concerned, &amp;quot;trunk&amp;quot; and &amp;quot;branches&amp;quot; are merely two folders under URL.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some commands can also use options which are given with dashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is yours to work with so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir and cp ==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then you might want to create a branch of your project, for instance to call it &amp;quot;version1&amp;quot; as you start to work on version2. branching is merely a copy so you can do it directly on the server also:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn cp -r URL/trunk URL/branches/version1 --message &amp;quot;Creation of the version1 branch.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you could check out URL/branches/version1 to work on version1 rather than the trunk.&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
The [http://svnbook.red-bean.com/ Subversion Red Book] is the bible of subversion. Very recommended.&lt;br /&gt;
&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the &amp;quot;Pragmatic Programming&amp;quot; course was useful and that you feel (at least a bit) more confident about coding on the Linux platform. Have fun.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5200</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5200"/>
		<updated>2008-05-15T14:52:02Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get information about your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by navigating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;trunk/&amp;quot; at the end of the URL is just a convention. usually, subversion repositories are organised so that the latest version is in the &amp;quot;trunk/&amp;quot; and other versions are in &amp;quot;branches/&amp;quot;. This is purely semantics, as far as subversion is concerned, &amp;quot;trunk&amp;quot; and &amp;quot;branches&amp;quot; are merely two folders under URL.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme commands can also use options which are given with dashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is yours to work with so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir and cp ==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then you might want to create a branch of your project, for instance to call it &amp;quot;version1&amp;quot; as you start to work on version2. branching is merely a copy so you can do it directly on the server also:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn cp -r URL/trunk URL/branches/version1 --message &amp;quot;Creation of the version1 branch.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you could check out URL/branches/version1 to work on version1 rather than the trunk.&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
The [http://svnbook.red-bean.com/ Subversion Red Book] is the bible of subversion. Very recommended.&lt;br /&gt;
&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the &amp;quot;Pragmatic Programming&amp;quot; course was useful and that you feel (at least a bit) more confident about coding on the Linux platform. Have fun.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5199</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5199"/>
		<updated>2008-05-15T14:45:52Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
The [http://svnbook.red-bean.com/ Subversion Red Book] is the bible of subversion. Very recommended.&lt;br /&gt;
&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the &amp;quot;Pragmatic Programming&amp;quot; course was useful and that you feel (at least a bit) more confident about coding on the Linux platform. Have fun.&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5198</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5198"/>
		<updated>2008-05-15T14:43:50Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5197</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5197"/>
		<updated>2008-05-15T14:43:15Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* To go further */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
The subversion bible is the [http://svnbook.red-bean.com/ Subversion Red Book]. It is very very thorough. Highly recommended.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5196</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5196"/>
		<updated>2008-05-15T14:42:06Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5195</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5195"/>
		<updated>2008-05-15T14:40:13Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Other useful commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5194</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5194"/>
		<updated>2008-05-15T14:39:02Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Other useful commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
If you rename a file or directory manually, you loose its history, this is because subversion needs to be notified that a tracked file or directory will have a new name. It is simpler to use the subversion &amp;quot;move&amp;quot; command. For instance, to rename &amp;quot;file2&amp;quot;, do: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn move file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You notice that the new file is added and the old one deleted. You could have done this manually but the advantage of this is that the history of the new file before the new name is still available.&lt;br /&gt;
&lt;br /&gt;
==import==&lt;br /&gt;
When you ask for a new repository, it is empty by default. To populate it, you can use the import command. (import is because the action is done from the server, it imports something). The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn import PATH URL/trunk --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* PATH is the path to the local folder (by default it ses &amp;quot;./&amp;quot;, i.e. the current folder)&lt;br /&gt;
* URL is the full URL of the repository. In the example, I also added &amp;quot;trunk/&amp;quot; at the end and the trunk would be created automatically.&lt;br /&gt;
&lt;br /&gt;
==mkdir==&lt;br /&gt;
Often people ask how then can create the &amp;quot;branches/&amp;quot; directory in the repository to store some specific versions of their code. This can be done by invoking mkdir directly on the server. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mkdir URL/branches --message &amp;quot;Log message.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==export==&lt;br /&gt;
Sometimes, you want to get the files from the version control system but this will not be used as a working copy, for instance you are going to send the files to somebody who is not involved in the development. For instance, it is the command that was used for the [[Linux1]] and [[Linux2]] practicals.&lt;br /&gt;
&lt;br /&gt;
You could do a checkout and remove all the hidden &amp;quot;.ssh&amp;quot; directories manually, but the easiest to to use the &amp;quot;export&amp;quot; command. It works exactly like a checkout except that you end up with a normal local folder, not a working copy. The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn export URL PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==merge==&lt;br /&gt;
When you have different branches in your project, you ight want to merge the changes from one branch to another. For instance somebody has fixed a bug in version 1 that is still present in the trunk. You might want to apply the changes done on version 1 directly on the trunk. Subversion allows you to do this and it is called a merge operation. This is really beyond the scope of this introduction but it is important to know it exists. You can refer to the [http://svnbook.red-bean.com Subversion Red Book] for more information about merging.&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5193</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5193"/>
		<updated>2008-05-15T14:23:37Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Creating the conflict */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Creating the conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modifies file1 by adding a line and commits (let's assume revision5)&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits (revision 6)&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
The update does not fail but file1 is flagged with the letter &amp;quot;C&amp;quot; indicating a conflict and you will notice new files in your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$svn status&lt;br /&gt;
?      file1.r5&lt;br /&gt;
?      file1.r6&lt;br /&gt;
?      file1.mine&lt;br /&gt;
C      file1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* file1.r5 is file1 as at revision 5 (i.e. the one at your last update)&lt;br /&gt;
* file1.r6 is file1 at revision 6 (i.e. the one that is on the repository now)&lt;br /&gt;
* file1.mine is file1 as it was in working copy before the update&lt;br /&gt;
* file1 contains an attempt at merging the changes&lt;br /&gt;
&lt;br /&gt;
Let's look at file1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat file1&lt;br /&gt;
Added this line.&lt;br /&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; .mine&lt;br /&gt;
This will create the conflict.&lt;br /&gt;
=======&lt;br /&gt;
This LINE will create the conflict.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; .r6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Subversion uses &amp;quot;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;quot; and &amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;quot; to show the problem(s). Your version of the problem lines is shown first (.mine) and then the version in the repository (.r6).&lt;br /&gt;
&lt;br /&gt;
To solve the conflict, you need to edit this file and mark it as solved. For instance, let's assume that your version was the good one (that's probably not a good assumption in normal development cycles as you are just ignoring one commit here). To resolve the conflict, one could do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cp file1.mine file1&lt;br /&gt;
$ svn resolved file1&lt;br /&gt;
Resolved conflicted state of 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you could commit your changes. But '''don't''' during the practical as all of you have resolved the conflict at the same time and this should be done only once.&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5192</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5192"/>
		<updated>2008-05-14T15:52:40Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=conflicts=&lt;br /&gt;
There are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
==Creating the conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
&lt;br /&gt;
==Resolving a conflict==&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5191</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5191"/>
		<updated>2008-05-14T15:51:38Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=conflicts=&lt;br /&gt;
There are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
==Creating the conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
&lt;br /&gt;
==Resolving a conflict==&lt;br /&gt;
&lt;br /&gt;
=conflicts=&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
there are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
==Creating a conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
==Resolving a conflict==&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5190</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5190"/>
		<updated>2008-05-14T15:49:31Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* conflicts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
=conflicts=&lt;br /&gt;
There are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
==Creating the conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
&lt;br /&gt;
==Resolving a conflict==&lt;br /&gt;
&lt;br /&gt;
=conflicts=&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
there are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
==Creating a conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
==Resolving a conflict==&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5189</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5189"/>
		<updated>2008-05-14T15:41:17Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard diff syntax is used with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=conflicts=&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
there are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
==Creating a conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
==Resolving a conflict==&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5188</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5188"/>
		<updated>2008-05-14T15:38:18Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=conflicts=&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
there are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
==Creating a conflict==&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
==Resolving a conflict==&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5187</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5187"/>
		<updated>2008-05-14T15:35:35Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Resolving conflicts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
there are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
there are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5186</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5186"/>
		<updated>2008-05-14T15:33:38Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* Resolving conflicts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It uses standard diff syntax with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
In this section we will create a conflict and see how it can be resolved. The word of warning is that subversion will not solve conflicts for you and often you should get in touch with the person who wrote the conflicting bit and have a chat...&lt;br /&gt;
&lt;br /&gt;
there are two types of conflicts. Conflicts that occur when you try to commit (i.e. the repository has changed since your last update) and those who happen when you update. The first type is nasty because the commit simply fails saying the working copy is out of date. The second type is easier because, although the conflict still happens, it is flagged properly and can be resolved more easily. A general rule is to always update before a commit and then only the second type of conflict happens.&lt;br /&gt;
&lt;br /&gt;
Let us create a conflict:&lt;br /&gt;
* Somebody modify file1 by adding a line.&lt;br /&gt;
* All of you update your working copies&lt;br /&gt;
* Person1 modifies the new line&lt;br /&gt;
* All of you modify the same line too&lt;br /&gt;
* Person1 commits&lt;br /&gt;
* Now all of you, try to update&lt;br /&gt;
&lt;br /&gt;
Now the conflict is flagged with the letter &amp;quot;G&amp;quot; and you will notice new files in the working copy.&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5185</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5185"/>
		<updated>2008-05-14T15:20:49Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It uses standard diff syntax with &amp;quot;+&amp;quot; for additions and &amp;quot;-&amp;quot; for deletions.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5184</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5184"/>
		<updated>2008-05-14T15:18:57Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* diff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5183</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5183"/>
		<updated>2008-05-14T15:18:13Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* blame */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
==blame==&lt;br /&gt;
Sometimes, you want to know who wrote a particular bit of code. Subversion makes that easy with the blame command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You see the content of file2 and for each line the name of the author and the revision number. You could then fetch the log message for that particular revision to get more information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log file2 --revision 3&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r3 | jprenaud | 2008-05-14 16:03:45 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
&lt;br /&gt;
More things.&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5182</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5182"/>
		<updated>2008-05-14T15:16:03Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* diff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It uses standard diff type syntax with &amp;quot;+&amp;quot; to show additions and &amp;quot;-&amp;quot; to show deletions. As with log, you can also use revision numbers.&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
	<entry>
		<id>https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5181</id>
		<title>Subversion</title>
		<link rel="alternate" type="text/html" href="https://source.geography.bristol.ac.uk/mediawiki/index.php?title=Subversion&amp;diff=5181"/>
		<updated>2008-05-14T15:15:06Z</updated>

		<summary type="html">&lt;p&gt;Jprenaud: /* diff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Pragmatic Programming]]&lt;br /&gt;
&lt;br /&gt;
=Version control concepts=&lt;br /&gt;
Subversion is a centralised version control system. Centralised version control means that a copy of your project is held in a central location called the '''repository''' and the subversion server logs all operations happening on the repository: everytime something is changed in the repository, the server logs the '''time and date''', the ''changes''', the '''author''' as well as a '''log message'''. The server can be configured to let some people do actions that other cannot. For instance, in the practical, the server allows anonymous read-only access but only a selected number of people can changes things.&lt;br /&gt;
&lt;br /&gt;
All the operations described above (logging and authentication) happen on the server. However, the server is only accessible directly to system administrators. To interact with the server, a user makes use of a subversion '''client'''. Some of you might already know about some graphical subversion clients such as TortoiseSVN. This practical will show how the command line client can be used. The subversion client can be used to (1) ask information from and (2) send information to the server. The client can also be used to get informationabout your '''working copy''' which is the local copy of the project that resides on your filespace. You can use the client to ask questions such as:&lt;br /&gt;
* which files have I modified since I last synchronised with the server?&lt;br /&gt;
* when was that file last modified?&lt;br /&gt;
* who wrote the stupid bug at line 18 in file foo.c?&lt;br /&gt;
* what has changed in that file?&lt;br /&gt;
&lt;br /&gt;
The repository that we are going to use for this practical is called subversion and is hosted in the &amp;quot;open&amp;quot; part of source server. You can access the repository directly by naviguating to [http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk]. This is not a very intuitive interface and we also provide a nicer interface called [http://source.ggy.bris.ac.uk/websvn websvn] and select the &amp;quot;subversion&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
If you don't have a subversion login, use [http://source.ggy.bris.ac.uk/websvn-open this link] instead, but then you will '''not''' be able to send anything to the server.&lt;br /&gt;
&lt;br /&gt;
Keep a websvn browser window open to check the state of the repository throughout the practical.&lt;br /&gt;
&lt;br /&gt;
=svn: the subversion command line client=&lt;br /&gt;
The subversion command line client is called &amp;quot;svn&amp;quot;. To execute a subversion command, simply type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn command arguments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Somme command can also use options which are given withdashes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn command arguments --option optionvalue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Subversion provides extensive help about the commands to use. To get help for a particular subversion command, simply use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn help command&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Getting the content for this practical=&lt;br /&gt;
You have used the subversion client for all the practicals in the [[:category:Pragmatic Programming | Pragmatic Programming]] course. To create a '''working copy''' of the repository type (first make sure you don't have a local folder called &amp;quot;subversion&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn checkout http://source.ggy.bris.ac.uk/subversion-open/subversion/trunk subversion&lt;br /&gt;
A    subversion/file1&lt;br /&gt;
A    subversion/file2&lt;br /&gt;
A    subversion/folder1&lt;br /&gt;
A    subversion/folder1/somefile&lt;br /&gt;
A    subversion/folder2&lt;br /&gt;
A    subversion/folder2/somefile&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
What this command does is import the content of the URL into a new folder called subversion. The letter &amp;quot;A&amp;quot; simply means that these files have been added.&lt;br /&gt;
&lt;br /&gt;
The content that you saw in websvn in now in your own file space. You will also notice hidden directories called &amp;quot;.svn&amp;quot;. It is '''very''' important that you do not touch these directories.&lt;br /&gt;
&lt;br /&gt;
=Modifying the working copy=&lt;br /&gt;
The working copy is your to work in so go ahead and modify some things. To simplify the practical, only modify the file named after you to start with (in the wiki, file2 was modified). To see what files you have modified, you ask the client for the status of your working copy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The status shows the letter &amp;quot;M&amp;quot; for file2, indicating it has been modified.&lt;br /&gt;
&lt;br /&gt;
Note that this status only shows the things that have changed in '''your''' working copy. Not the changes made by others of on the server.&lt;br /&gt;
&lt;br /&gt;
You can also add a new file. Name the new file after your name and add a suffix. &amp;quot;newfile&amp;quot; is used in the wiki:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ touch newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
?      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interogation mark shows that the subversion client does not know what to do with the new file. By default, svn will ignore new files. To indicate that a new file should be versionned, use the add command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn add newfile&lt;br /&gt;
A         newfile&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the letter &amp;quot;A&amp;quot; is used showing an addition.&lt;br /&gt;
&lt;br /&gt;
The same things happen for deletions. Let's try to delete file1 for instance:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rm -f file1&lt;br /&gt;
$ svn status&lt;br /&gt;
!      file1&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
$ svn delete file1&lt;br /&gt;
D         file1&lt;br /&gt;
$ svn status&lt;br /&gt;
D      file1&lt;br /&gt;
M      file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The letter &amp;quot;D&amp;quot; is used for deletions.&lt;br /&gt;
&lt;br /&gt;
Subversion allows you to revert changes when you have made an error. Let's assume that file1 was deleted by error, you can get it back with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn revert file1&lt;br /&gt;
Reverted 'file1'&lt;br /&gt;
$ svn status&lt;br /&gt;
M      file2&lt;br /&gt;
A      newfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to send all these changes to the server. To avoid conflicts at this stage, make sure that you have only modified files containing your name (although this wiki page uses file2 and newfile). If you have modified anything else, revert the relevant changes.&lt;br /&gt;
&lt;br /&gt;
=Sending changes to the repository=&lt;br /&gt;
&lt;br /&gt;
Sending changes to the repository is called a '''commit'''. The syntax to commit your changes is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
Sending        file2&lt;br /&gt;
Adding         newfile&lt;br /&gt;
Transmitting file data ..&lt;br /&gt;
Committed revision 2.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might have noticed the revision number. You should all get different revision numbers are your commits will be done one after the other. Because you have all worked on separate files, there is no risk of conflicts and subversion will happily combine all your changes together. Have a look in websvn (refresh the page) to see the state of the repository.&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a long message to go with a commit. To do this, simply execute the commit without the --message option. A text editor will then popup to be used to write the commit and by saving-exiting, the commit will be done. Note that svn use the editor stored in the EDITOR environment variable and often defaults to vi if this variable is undefined. So if you are an emacs fan, set the variable first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ export EDITOR=emacs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this stage in the practical you and others have sent changes to the server. To bring these changes back to your working copy, you need to update it.&lt;br /&gt;
&lt;br /&gt;
=Updating your working copy=&lt;br /&gt;
&lt;br /&gt;
To update your working copy, simply run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn commit [--message &amp;quot;Log message.&amp;quot;] [--username subversionlogin]&lt;br /&gt;
... &amp;lt;- list of files that have been added/modified&lt;br /&gt;
At revision 8.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, because you have all worked on separate files, there is no risk of conflicts and subversion should fetch all the changes without problem.&lt;br /&gt;
Your working copy contains now all the bits and pieces chenged by other people. A lot neater that emailing batches files etc, no?&lt;br /&gt;
&lt;br /&gt;
status, commit and update will probably be your most widely used commands:&lt;br /&gt;
* update regularly to bring other people's work&lt;br /&gt;
* status to make sure all is well&lt;br /&gt;
* commit&lt;br /&gt;
&lt;br /&gt;
However the subversion client can also be used to looks at changes in the repository and this can boost productivity.&lt;br /&gt;
&lt;br /&gt;
=Investigating changes=&lt;br /&gt;
This section shows some subversion commands. Some of these commands can also be done directly from the websvn interface.&lt;br /&gt;
&lt;br /&gt;
==log==&lt;br /&gt;
To get a log of what happened in the repository, use the log command. To see the files that have been modified as well as the log messages, use the --verbose option:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r2 | jprenaud | 2008-05-14 15:18:44 +0100 (Wed, 14 May 2008) | 1 line&lt;br /&gt;
Changed paths:&lt;br /&gt;
   M /trunk/file2&lt;br /&gt;
   A /trunk/newfile&lt;br /&gt;
&lt;br /&gt;
First commit&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
r1 | jprenaud | 2008-05-14 13:42:43 +0100 (Wed, 14 May 2008) | 2 lines&lt;br /&gt;
Changed paths:&lt;br /&gt;
   A /trunk&lt;br /&gt;
   A /trunk/file1&lt;br /&gt;
   A /trunk/file2&lt;br /&gt;
   A /trunk/folder1&lt;br /&gt;
   A /trunk/folder1/somefile&lt;br /&gt;
   A /trunk/folder2&lt;br /&gt;
   A /trunk/folder2/somefile&lt;br /&gt;
&lt;br /&gt;
Initial import into the repository.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also invoke the log command on a particular file/path and provide a range of revisions.&lt;br /&gt;
For instance to see which commits affected file1 between revisions 4 and 6, one could use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn log --verbose --revision 4:6 file1&lt;br /&gt;
... &amp;lt;- log output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==diff==&lt;br /&gt;
After you have modified something, it's sometimes nice to see what you've actually done. This is done with the diff command. For instance add some text to file1 and use diff to see what you have done.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn diff file1&lt;br /&gt;
Index: file1&lt;br /&gt;
===================================================================&lt;br /&gt;
--- file1       (revision 3)&lt;br /&gt;
+++ file1       (working copy)&lt;br /&gt;
@@ -1 +1,4 @@&lt;br /&gt;
-Added this line.&lt;br /&gt;
+Added this (removed some text here)&lt;br /&gt;
+&lt;br /&gt;
+Add a new line here&lt;br /&gt;
+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==blame==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn blame file2&lt;br /&gt;
     2   jprenaud Added some stuff&lt;br /&gt;
     3   jprenaud Another line&lt;br /&gt;
     4   jprenaud A third line.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Resolving conflicts=&lt;br /&gt;
&lt;br /&gt;
=Other useful commands=&lt;br /&gt;
==move==&lt;br /&gt;
Rename&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ svn mv file2 new_file2&lt;br /&gt;
A         new_file2&lt;br /&gt;
D         file2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==import==&lt;br /&gt;
==mkdir==&lt;br /&gt;
==export==&lt;br /&gt;
==merge==&lt;br /&gt;
&lt;br /&gt;
=To go further=&lt;br /&gt;
Subversion red Book&lt;br /&gt;
=Pragmatic Programming=&lt;br /&gt;
That's all folks. We hope you have the right basis to be&lt;/div&gt;</summary>
		<author><name>Jprenaud</name></author>
	</entry>
</feed>