CVS to SVNbook Crossover Guide

Key Differences between CVS and Subversion

Structure

This is the location of the M3DP project repository on pppl svn server. m3dp/ This is the subproject. trunk, branches tags
https://svnsrv.pppl.gov/svn/repos/
This is the location of the M3D project repository on pppl server.
m3dp/
This is the subproject.
trunk
main branch of development.
branches
tags

NEW FEATURES: Browsing a repository linear mhd component svn repository at svnsrv.pppl.gov

Browse the repository as a filesystem, perusing file contents and history as well (older versions of files or trees.)

CVS Subversion
Commands:
(not possible with commandline client)
Explanation:
Not possible with commandline client. A third-party web server tool such as ViewCVS must be used.
Commands:
$ svn list http://svnsrv.pppl.gov/svn/repos [-r rev] [-v]
$ svn cat http://svnsrv.pppl.gov/svn/repos [-r rev]
Explanation:
The svn list and svn cat commands allow interactive browsing of a repository (and all previous states of a repository) from the commandline. (The --verbose [-v] switch displays full listing information.) If Apache is being used as a Subversion server process (i.e. clients access via http://), then the latest version of the repository can be directly browsed by entering URL into any web browser. Additionally, a third-party web server tool (such as ViewCVS) can be used with Subversion.

NEW FEATURE: Undoing Working Changes

CVS Subversion
Commands:
impossible
Commands:
svn revert file
Explanation:
reverts the file to its pre-modified state; can undo any scheduled operations: e.x., you might decide that you don't want to add a new file after all; or perhaps you mistakenly removed a file from version control.

NEW FEATURES: Copying and moving

Copy or move/rename a file or directory.

CVS Subversion
Commands:
(not possible.)
Explanation:
Not possible, unless an administrator directly mucks with RCS files in the repository. (And in that case, no history records the act of copying or renaming.)
Commands:
$ svn copy foo.c foo2.c
A     foo2.c
 
$ svn copy dir dir2
A     dir2
 
$ svn move bar.c baz.c
A     baz.c
D     bar.c
 
$ svn move dirA dirB
A     dirB
D     dirA/file1
D     dirA/file2
Explanation:
The svn copy command schedules a file or directory for addition to the repository, recording the "source" of the copy. After committing, svn log on the copied item will trace history back through the original copy-source. The svn move command is exactly equivalent to running svn copy, followed by an svn delete on the copy-source: the result is a new item scheduled for addition (with copy-history attached) and the original item scheduled for deletion.

Common FEATURES: Repository creation

Create a new repository for holding versioned data.

CVS Subversion
Commands:
$ cvs -d /usr/local/repos init
Explanation:
Creates a new directory repos ready to hold M3D files and config scripts.
Commands:
$ svnadmin create http://svnsrv.pppl.gov/svn/repos
Explanation:
Creates a new directory repos containing M3D files and config scripts.

Common FEATURES: Authenticating to a server

Have a network client prove its identity to a version control server.

CVS Subversion
Commands:
$ cvs -d :pserver:user@host:/repos command
Explanation:
When contacting a repository, the client pre-emptively "pushes" its authentication credentials at the server.
Commands:
$ svn command http://svnsrv.pppl.gov/svn/repos
Password for 'user':  XXXXXXX
Explanation:
The client's authentication credentials are "pulled" from the user interactively, and only when the server deems that a challenge needs to be made. (And contrary to popular belief, the --username and --password options are merely values to be used if the server issues a challenge; they do not "push" the credentials at the server.)

Common FEATURES: Importing data

Populate a new repository with initial data. Assuming that you have a tree of code in the local directory myproj/, and you want to move this tree into the repository.

CVS Subversion
Commands:
$ cd myproj
$ cvs -d /usr/local/repos import myproj/ none start
Explanation:
This copies the contents of the current working directory to a new directory (myproj) in the CVS repository. The CVS repository now contains a directory /myproj/ at the top level.
Commands:
$ svn mkdir http://svnsrv.pppl.gov/svn/repos/tags
$ svn mkdir http://srnsrv.pppl.gov/svn/repos/branches
$ svn import myproj/ http://svnsrv.pppl.gov/svn/repos/trunk
Explanation:
Though not strictly required, we deliberately create /tags and /branches top-level directories in the repository, to hold tags and branches later on. Then we import the contents of the local myproj/ directory into a newly created /trunk directory in the repository.
Another Way:
mkdir tmpdir
cd tmpdir
mkdir projectA
mkdir projectA/trunk
mkdir projectA/branches
mkdir projectA/tags
mkdir projectB
mkdir projectB/trunk
mkdir projectB/branches
mkdir projectB/tags
svn import . http://svnsrv.pppl.gov/svn/repos --message 'Initial repository layout'
  Adding projectA
  Adding projectA/trunk
  Adding projectA/branches
  Adding projectA/tags
  Adding projectB
  Adding projectB/trunk
  Adding projectB/branches
  Adding projectB/tags
  Committed revision 1.
cd ..
rm -rf tmpdir
svn list --verbose http://svnsrv.pppl.gov/svn/repos

Common FEATURES: Checking out a working copy

Create a workspace on local disk which mirrors a directory in the repository.

CVS Subversion
Commands:
$ cvs -d /usr/local/repos checkout myproj
U myproj/foo.c
U myproj/bar.c
Explanation:
Creates a local directory myproj which is a mirror of the repository directory /myproj.
Commands:
$ svn checkout http://svnsrv.pppl.gov/svn/repos/trunk myproj
A  myproj/foo.c
A  myproj/bar.c
Explanation:
Assuming that the original project data was imported into the repository /trunk directory, this creates a local directory myproj which is a mirror of the repository directory /trunk. Standard Subversion convention is to do "mainline" development in /trunk. See branching and tagging sections for more details.

Common FEATURES: Seeing locally changed and out-of-date items

Discover which items in the working copy have local modifications or are scheduled for addition/deletion.

CVS Subversion
Commands:
$ cvs update -n
Explanation:
The cvs udpate -n command shows whether a file is locally modified or out of date, including information about working revision and branch info without actually updating the working copy.
Commands:
$ svn status
Explanation:
Shows modified files only. Very fast, as it does not use the network. Does not update your working copy, yet still shows a single-line display, much like svn update. To see working revision and branch information, run svn info.

Common FEATURES: update working copy

CVS Subversion
Commands:
$ cvs update
Commands:
$ svn update
Explanation:
svn remembers that a file is in a state of conflict, and won't allow you to commit your changes until you run svn resolved.

Common FEATURES: Examine the details of your local modifications

CVS Subversion
Commands:
cvs diff
Explanation:
Shows you the details of your changes
Commands:
svn diff
Explanation:
Shows you the details of your changes. Files scheduled for addition are displayed as all added-text, and files scheduled for deletion are displayed as all deleted text. Output is displayed in unified diff format. That is, removed lines are prefaced with - and added lines are prefaced with +. "svn diff > patchfile" prints filename and offset information useful to the patch program.

Common FEATURES: Resolve conflicts

CVS Subversion
Commands:
Commands:

Common FEATURES: Scheduling additions or deletions

Schedule a working-copy file or directory to be added or removed from the repository.

CVS Subversion
Commands:
$ touch foo.c
$ cvs add foo.c
cvs server: scheduling file `blah' for addition
cvs server: use 'cvs commit' to add this file permanently
 
$ mkdir new-dir
$ cvs add new-dir
Directory new-dir added to the repository
 
$ rm bar.c
$ cvs rm bar.c
cvs remove: scheduling `bar.c' for removal
cvs remove: use 'cvs commit' to remove this file permanently
 
$ rm -rf old-dir/*
$ cvs rm old-dir
cvs remove: Removing 3bits
Explanation:
Schedules a file or directory for addition or removal to/from the repository. The repository will not be changed until the user runs cvs commit, except for the case of adding a directory, which immediately changes the repository. Also, directories cannot be truly removed from the repository, just emptied out. (cvs update -P will prune empty directories from your working copy.)
Commands:
$ touch foo.c
$ svn add foo.c
A     foo.c
 
$ mkdir new-dir
$ svn add new-dir
A     new-dir
 
$ svn rm bar.c
D     bar.c
 
$ svn rm old-dir
D     old-dir/file1
D     old-dir/file2
Explanation:
Schedules a file or directory for addition or removal to/from the repository. The repository will not be changed until the user runs svn commit. The scheduled operations are shown as A or D by svn status, and svn revert can un-do the scheduling. Directories really can be deleted (though as with all deleted items, continues to exist in history.)

Common FEATURES: Commit Your Changes

CVS Subversion
Commands:
svn commit -m "Corrected number of cheese slices."
Commands:
svn commit -m "Corrected number of cheese slices." -F logmsg
Explanation:
If somebody has changed any of the same files that you did when you weren't looking, the entire commit will fail with a message informing you that one or more of your files is out-of-date: