Search/Navigation:
Related:
SLAC/EPP
/HPS Public
Jefferson Lab/Hall B
/HPS Run Wiki
S30XL-LESA/LDMX
Table of Contents | ||||
---|---|---|---|---|
|
This page is a detailed primer on how to use Subversion for software development. It includes definitions of basic terminology plus explanations and examples of basic commands
It includes definitions of basic terminology plus explanations and examples of basic commands.
The version of Subversion (no pun intended) is important because older versions are not compatible with newer ones, meaning you cannot checkout a project with say 1.8 and then use a 1.6 client on it. This is because the metadata formats used to track local files changes with minor release numbers in incompatible ways.
You can use this command to upgrade your local copy from an older client to the newer one.
No Format |
---|
cd sandbox; svn upgrade . |
You should also make sure that your IDE's Subversion library is compatible with the command line client (covered in Project Development in Eclipse).
Here are some basic terms with which you should be familiar in order to understand the rest of this guide.
...
A working copy is your local version of any SVN module or file from the remote repository. Executing an svn checkout will create a local copy of a file or directorysvn checkout will create a local copy of a file or directory.
The master copy refers to the current version of a file on the SVN server, as opposed to a local copy on your computer.
Executing a commit will push your changes on to one or more files or directories to the remote repository, making the master copy match your current local copy of those files.
A revision in SVN is a globally unique identifier, starting with 'r', that tags the state of the repository at some particular time. Every commit will create a new revision. The revision numbers are numbered sequentially from 1 to however many revisions have been created. (SVN actually tracks revisions globally rather than on a per file basis.)
URLs in SVN are used to identify paths on the remote server which has the master copy of the source code. In the case of Subversion, these . These will have svn:// as the protocol. (SVN supports other protocols as well such as https.)
For example, svn://svn.freehep.org/hps is the URL for the HPS Subversion repository.
...
In general, if you execute svn commands within a local directory that is tracked by Subversion, they will be interpreted correctly.
The base URL node of the remote repository such as svn://svn.freehep.org/hps/. This is similar to the root node in a file system.
The "^" character can be used to specify the repository root for any command that accepts a Subversion URL.
...
Any part of the repository under the root. Structure nodes can be conceptualized as a sub-directory on a file system, with the repository root as the root directory.
This is a copy of some directory the code at a certain point in time like , usually when a release is made. By convention, a tag should not be modified once created. They are usually kept in a node called 'tags'.
...
This is a fork of the trunk, or even of another branch, which is for development and can be modified after it is created. Branches are usually kept in a node called 'branches'.
To merge means combining together two nodes in order to merge their changes togetherMerging will combine together the contents of two nodes. This usually occurs when a branch should be reintegrated into the trunk or another branch.
To revert means clobbering your local changes in the working copy and replacing them with the current copy from the remote repository.
...
This is an example of listing contents of a relative path.
No Format |
---|
svn ls trunk/parent |
...
No Format |
---|
svn ls svn://svn.freehep.org/hps/java/trunk |
...
This is an example of making a branch.
No Format |
---|
svn cp -m "Making a new HPS Java branch for some reason." ^/projects/hps/java/trunk ^/projects/hps/java/branches/hps-java_HPSJAVA-123 |
Note here that we have included The name of the branch is 'HPSJAVA-123' in the name as a reference to a relevant ' to reference a JIRA item. (This This is just a dummy name. In actuality, it should be a real JIRA item. ) This This allows someone to understand the purpose of that branch from its name.
Warning | ||
---|---|---|
| ||
Merging is an advanced operation, and should not be done without some forethought. Always use '--dry-run' to check the results of the command before actually executing it. And always merge equivalent structure nodes when merging a branch back into the trunk, or you will screw up the trunk. |
...
Using the above example branch, the following is the equivalent merge operation.
No Format |
---|
svn merge ^/projects/hps/java/branches/hps-java_HPSJAVA-123/ ^/projects/hps/java/trunk |
In general, unless very minor changes were made to the code on the branch, you should always communicate with the other developers about plans for merging and what the state of the trunk will be after the merge is performed.
After a merge, the changes (additions, deletions, etc.) are only made to the local copy and must still be committed, using the usual commit command.
...
For instance, this command will revert a single local file to its master copy, removing any changes you have made on it locally.
No Format |
---|
svn revert sandbox/castles.txt |
...
The command will execute immediately unlike an addition or deletion.
You can also revert entire nodes recursively, which will replace all changes in and under that node with the master copy.
No Format |
---|
svn revert sandbox --recursive |
You should be careful when reverting entire nodes, as this will completely clobber any changes you have made.
Using revert results in changes to your local copy that are not recoverable e.g. all your local edits will be removed. So be careful when using this command.
...