From WeBWorK
Revision as of 12:30, 20 June 2010 by Aubreyja (Talk | contribs)
Jump to: navigation, search
Construction.png This article is under construction. Use the information herein with caution until this message is removed.

See also: History of WeBWorK version control

WeBWorK uses the Subversion version control system. Subversion's command-line interface is similar to CVS, and was developed to both improve upon CVS but to also be very easy for CVS users to learn. All WeBWorK installations should be transferred from CVS to SVN. Instructions for doing so can be found in Converting a CVS checkout to SVN.

This article gives a brief introduction to Subversion, how to use it to download (or checkout) the WeBWorK code, and how to keep your downloaded code (your working copy) up to date. If you are a WeBWorK developer or plan to start doing WeBWorK development, please also see SVN Commit Access. For a complete guide to Subversion, read the book Version Control with Subversion. This book is especially recommended for WeBWorK developers.


Installing Subversion

To use Subversion, you have to obtain the official command line Subversion client. Most Linux distributions will have this available in their package repositories, and many install it by default. For example,

  • to install Subversion in Ubuntu do sudo apt-get install subversion
  • to install Subversion in Fedora become root and do yum install subversion

If you use another Linux distribution or a Unix distribution, please check your OS's documentation for precise instructions on installing Subversion. (Also, please feel free to add those instructions to the list above.) Command line and GUI clients are also available for the Windows and Macintosh operating systems.

The repositories

The WeBWorK subversion repositories store all of the WeBWorK code and the National Problem Library. These repositories are hosted by the MAA at and, in fact, all of the code may be viewed on the web. Subversion also stores the history of all changes to WeBWorK, and copies of all development and production releases.

There are two main WeBWorK repositories. The two repositories are

  • system containing the core WeBWorK and PG code, and
  • npl containing the National Problem Library.

These two repositories contain all of the necessary WeBWorK software and the National Problem Library. There may be a few other problem library repositories (such as rochester), but those will soon be folded into the NPL.

If you look into these repositories, you will find three main subdirectories. Each repository uses a the fairly standard hierarchy:

  • branches
  • tags
  • trunk

The primary development work is done in the trunk subdirectory. WeBWorK itself is in the webwork2 subdirectory of the trunk, and the PG code is in the pg subdirectory of the trunk. Since many WeBWorK servers run the code in this tree for production usage, patches made in this tree must not break the code. Developers should also avoid rewriting extensive portions of the trunk as well. Such work is typically done in development branches. The trunk of the system repository has many other subdirectories, but these contain specialized sub-projects.

branches is used for major coding work, testing huge patches, and testing unstable patches. Some developers may have their own branch of the code here. It is also used to prepare new stable releases. Each major stable series gets its own directory as rel-<major_version>-<minor_version> or rel-<major_version>-<minor_version>-patches. For example, the current stable release of the WeBWorK code is rel-2-4-patches.

tags is a special hierarchy used to save the state of the software at a given point in the time. You should NEVER make any change to it as this is only useful when releasing new versions. That task is handled solely by the WeBWorK release managers.

The access mechanism to the WeBWorK subversion repositories allows anonymous users to perform any operation which involves only reading data from the repository. For most users, this usually means just svn checkout and svn update, but there are many other more specialized read only subversion commands detailed in [1].

Writing data to the repository (such as modifying the WeBWorK code) requires commit access. Like most open-source projects which use a version control system for source code management, the WeBWorK developers grant commit access on a case-by-case basis to individuals who wish to get involved with WeBWorK development and have demonstrated the skills for doing so. See Commit access requests for more information on obtaining commit access, and SVN Commit Access for a discussion of how to use it for development.

Anonymous use

As mentioned above, the WeBWorK repositories are configured so that anonymous users may perform any read operation (such as svn checkout, svn update, etc.) Below, we discuss the basic use of the most common read-only operations. This article does not discuss commands useful to developers who have commit access. That information can be found in SVN Commit Access.

Check out

The most common use of subversion is to download or checkout the WeBWorK software. In fact, we strongly recommend that you obtain the code from subversion when installing WeBWorK. For each stable release, we also provide a compressed tarball containing all of the necessary software, but installing from the tarball makes in much more difficult to keep up with updates and bugfixes.

First, you have to check out the WeBWorK code. To do so use the following syntax:

svn checkout some_target_directory

You can browse the code structure using the web interface (ViewVC). Under system the three folders there are used for different purposes:

  • The trunk is the main development branch.
  • The branches are used for stable versions of the core WeBWorK and PG code; and for the development of complex features.
  • The tags are used to track the released versions.

The URL structure is:

/svn/system or /svn/npl/ (or /svn/rochester/)
/trunk, or /branches/rel-2-4-patches, or /tags/rel-2-4-7
/webwork2 or /pg

Unlike the old CVS, the URL is used to specify the branch or the tag.

To check out the WeBWorK 2 development trunk into the folder "webwork":

svn co webwork

To check out the PG development trunk into the folder "webwork":

svn co webwork

To check out the National Problem Library development trunk into the folder "webwork/libraries":

svn co webwork/libraries

To check out the latest bits in some particular release branch:

svn co some_target_directory
svn co some_target_directory

To check out a specific version of the software:

svn checkout some_target_directory
svn checkout some_target_directory

Each time a commit is made to a repository, Subversion increments the revision number of the repository. To check out a specific revision of the webwork2 code, say revision 6000, do

svn checkout some_target_directory
svn checkout -r 6000 some_target_directory

or, if you want to switch to that revision, use the update command:

svn update -r <number>

Don't leave off the "trunk" or branch part! If you leave that off you check out every revision of every file in the repo, which is pretty silly and takes a long time.

Updating the working copy

To update your working copy and get the latest files, use the following command:

svn update (or just: "svn up")

Note that SVN, unlike CVS, doesn't need to be told to prune removed files or create new directories. This is automagic.

For a simple way to keep abreast of changes, one could use e.g.,

cp RELEASE-NOTES /tmp && svn up && diff /tmp RELEASE-NOTES
What happens if I change some file, then do "svn up" and it was changed upstream too?
Don't worry. You will see
Conflict discovered in 'lib/WeBWorK/'.
Select: (p) postpone, (df) diff-full, (e) edit, (h) help for more options:

Making a diff

Diffs, or patches, are text files which include all the changes done in the working copy. If you suggest a new feature in Bugzilla and would like to suggest a change which fixes it, upload a patch.

To create a diff from the current repository, use the following command:

svn diff

Normally, unlike CVS, you don't have to tell SVN which files you changed; however, you may like to diff only a part of the repository. To do that, specify the files to diff:

svn diff webwork2/lib/WeBWorK/

Note that SVN defaults to the "unified" diff format, so the "-u" option doesn't have to be passed.

Applying a diff

Subversion does not contain a built in command to apply diffs to the current working copy (for example, to review or commit diffs published in Bugzilla); instead, you can use the regular patch unix utility:

patch -p0 < patch_file

Changing file structure

You can add files or folders to the working copy, to be included in the next diff or commit, using the command:

svn add

If you add a folder, it will add all the files included in the folder, except for files in the ignored list.

You can delete files or folders from the working copy, to be deleted in the next commit or marked as such in the next diff, using the command (which will automatically delete the files from the working copy, but won't delete folders in such way):

svn delete

Make sure the file or folder do not have local modifications, else they won't be deleted unless you force the deletion.

Reverting your changes

If your changes in the working copy are not useful in your opinion, you can revert them using the following command:

svn revert

You must use parameters for this command. To revert all your changes in the working copy, use:

svn revert -R .

To revert the changes in a specific file, use:

svn revert

Reverting can also remove added files (they won't be deleted, just removed and considered "unknown files", just like you didn't use svn add at first), and restore deleted files (both deleted by hand and deleted by svn delete).

Checking the status of the working copy

You can check the status of your working copy using the following command:

svn status

These are several important letters in the first column of the item, which show the status:

  • M = the item was modified by you
  • A = the item was added by you (using svn add)
  • D = the item was deleted by you (using svn delete)
  •  ? = the item is not under the version control, but exists
  •  ! = the item is missing (under the version control, but does not exist - probably deleted without using svn delete) or incomplete

Developer use

Auto properties

See Subversion/auto-props for how to enable automatic line-ending conversion for files you add. Every developer should use it.


Commits, or check ins, are the action of applying your changes from the working copy to the web repository. Assuming you have commit access with username <user_name> and password <password>, then you may use either of the following commands to do that:

svn commit --username <user_name> --password <password> --message="This is the log comment."
svn commit --username <user_name> --password <password> --file=file_with_log_comment

You may also abbreviate commit as ci.

Please note that Subversion requires you to enter a log message for every commit. Also note that in your log message, if you refer to variables using Perl's '$' notation, remember to escape them from the shell.

See also

External links

follow us