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.
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 WeBWorK subversion repositories store all of the WeBWorK code and the National Problem Library. These repositories are hosted by the MAA at http://wwrk.maa.org/svn/ 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
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:
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 .
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.
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.
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 WeBWorK from the tarball makes in much more difficult to keep up with updates and bugfixes, and should only be done if subversion cannot be used for some reason.
First, you have to check out the WeBWorK code. To do so use the following syntax:
svn checkout http://wwrk.maa.org/svn/folders_to_download some_target_directory
- 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 http://svn.webwork.maa.org/system/trunk/webwork2 webwork
To check out the PG development trunk into the folder "webwork":
svn co http://svn.webwork.maa.org/system/trunk/pg webwork
To check out the National Problem Library development trunk into the folder "webwork/libraries":
svn co http://svn.webwork.maa.org/npl/trunk/NationalProblemLibrary webwork/libraries
Many institutions run their WeBWorK installation off of the trunk, and developers are careful to allow this by ensuring changes in the trunk are incremental and do not break the code. In that case the previous three commands will get you all of the WeBWorK software you need to install the system on your machine. (See the appropriate installation manual for information on how to configure your system and complete your WeBWorK installation from here.)
Many other institutions prefer to run their WeBWorK installation off of the current stable release. Doing so will provide a bit more stability. However, updates to such releases only include bugfixes, and you may not have access to the latest features until you upgrade to a new stable release containing those features. This is a trade-off, and each institution will must this decide for themselves.
To checkout the current stable release of the webwork2 and pg code to the folder webwork, do
svn co http://svn.webwork.maa.org/system/trunk/webwork2 webwork svn co http://svn.webwork.maa.org/system/trunk/pg webwork
Note that the National Problem Library repository is not branched - the trunk should always be used. Updates to the NPL usually include only bugfixes in library problems, and occasionally include the addition of new problem libraries contributed from institutions which use WeBWorK. Such changes will never affect the stability or security of your WeBWorK installation, and so regardless of whether your WeBWorK installation is run from the trunk or from the current stable release, you should use the command
svn co http://svn.webwork.maa.org/npl/trunk/NationalProblemLibrary webwork/libraries
to checkout the National Problem Library.
One final comment on branches: All stable releases of the WeBWorK 2 code can be checked out of the repository from 2.0 up to the current stable release (i.e. rel-2-0-patches, rel-2-1-patches, rel-2-2-patches, etc. up to the current stable release). Again, there are no corresponding branches for the NPL, just get the trunk.
Now we come to the third of the three main divisions in the repository: tags. Tags are simply used to mark a particular state of the files in the repository, and are generally used for development purposes or for preparing a stable release (which will appear as a branch). These tagged versions of the software can be checked out just like the trunk or any branch.
For example, the rel-2-4-7 tag is used to mark a particular point in the changes to the WeBWorK code released as version 2.4. To check out this particular version of the webwork2 and pg code do:
svn co http://svn.webwork.maa.org/system/tags/rel-2-4-7/webwork2 svn co http://svn.webwork.maa.org/system/tags/rel-2-4-7/pg
Each time a commit is made to a repository, Subversion increments the revision number of the files and directories changed by the commit. Revision numbers allow users very fine-grained control over exactly which version of the software they check out. Subversion will report the current revision number each time a checkout is made.
For example, to check out a specific revision in the trunk of the webwork2 code, say revision 6000, do
svn co http://svn.webwork.maa.org/system/trunk/webwork2@6000 some_target_directory or svn checkout -r 6000 http://wwrk.maa.org/svn/system/trunk/webwork2 some_target_directory
This can be useful, for example, if your installation is tracking the trunk, and some change is made which breaks your installation or causes unwelcome behavior (rare, but possible). In that case, you can switch to the last known good revision (or any revision) with the command
svn update -r <number>
Error creating thumbnail: /var/lib/mediawiki/bin/ulimit4.sh: line 4: rsvg: command not foundWarning:
|Don't leave off the "trunk", "branch" or "tag" part of any checkout. 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/WeBWorK.pm'. 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:
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/MyAwesomeWorK.pm
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 file.name
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 file.name
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:
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 file.name
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
Checking the status of the working copy
You can check the status of your working copy using the following command:
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
- D = the item was deleted by you (using
- ? = 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
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.