Introduction
This page describes some procedures related to using Subversion.
Procedures
Creating new modules
- If you have not already done so, then create a directory for storing copies of your modules while you work on them by running:
mkdir ~/svnwcs cd ~/svnwcs
- Think of a name for your module; you’ll get ideas about naming and about naming conventions by running:
svn ls https://svn.pasta.freemyip.com/
- Run the following commands:
MODULE="<name-of-module>" # E.g. MODULE="my-module" mkdir $MODULE ( cd $MODULE && mkdir trunk tags branches ) ( cd $MODULE/trunk && mkdir doc ) ( cd $MODULE/trunk/doc && touch ChangeLog )
- Populate $MODULE/trunk/; this probably means creating suitably named directories there (e.g. ‘bin’, ‘src’, ‘lib’) and then copying previously-written files into them or perhaps editing new files and saving them there. Afterwards run:
cd ~/svnwcs
- Edit $MODULE/trunk/doc/Changelog to contain something like:
* <name-of-module>: created module using my first version of <name-of-module>
- Save the new module back to the repository by running:
svn import $MODULE https://svn.pasta.freemyip.com/main/$MODULE
(This will launch an editor in order to write a commit log; use the same text you added to the ChangeLog.)
- If all went well you can delete the <name-of-module> directory but it is probably safer to run:
mv $MODULE $MODULE.deletesoon
Modifying modules
- You will need to know the URL where the program is archived; let’s call this <module-url> (e.g. https://svn.pasta.freemyip.com/main/my-module); if you just created the module, then the URL is the same as you used in the ‘svn import‘ command.
- Run:
cd ~svnwcs
- If you have not already checked out your module, or you did but you deleted it afterwards, then run:
svn co <module-url>/trunk <module-name>
(Specifying <module-name> is optional, but if you omit it then new directory into which the module is copied is named after the last component of the thing you check out, which in this case would be ‘trunk’, which is not a very helpful name.)
- Run:
cd <module-name>
(Note that now ‘trunk’, ‘branches’ and ‘tags’ are not present; this is because you just specified that it was only the ‘trunk’ sub-directory that you wished to get a copy of.)
- Edit the program, test it, edit it again, test it again, until you are happy it works.
- cd to the module’s top directory (this is in order that the following commands apply to the whole of the module’s trunk and not just a particular subdirectory of it (e.g. ‘bin’).
- Update doc/ChangeLog and add a comment about what changes you have made. (You might find that the output of the commands:
svn st svn diff
helps you to compile a log entry. Also useful is to run:
svn diff > diffs
and edit the diffs file down to ChangeLog-style entries; that file can then be imported in the the doc/ChangeLog and used as the commit log when you commit.)
- Commit your changes back to the repository by running:
svn commit
(This will launch an editor in order to write a commit log; use the same text you added to the ChangeLog.)
Inserting SVN replacement tokens in your scripts
- Put the following text near the top of your files:
$HeadURL$ $LastChangedRevision$
Very often it makes sense to put this text in a comment (the syntax for a comment depends on the language you’re module is written in (but see Wikipedia) or, if your file is a program source, to embed this text in your program’s code so that it gets compiled in when you compile the program.
- Run the following command:
svn pset svn:keywords "HeadURL LastChangedRevision" <your-script-file>
(Note that the quoted string is correctly spread over two lines.)
- Check the status with:
svn st
It should report:
MM <your-file>
- Add something to the ChangeLog like:
* <your-module>: added SVN replacement tokens and added SVN properties to ensure their timely substitution
- Commit as usual.