print
statementsFigure 5.1: Managing Multi-Author Collaboration
CVS
and Subversion
are:
CVS
has been around since the 1980s
Subversion (svn)
developed from 2000 onward as a workalike replacementsolarsystem
project repositorysvn update
to synchronize his working copy with the repositoryjupiter
directory and creates moons.txt
Name Orbital Radius Orbital Period Mass Radius Io 421.6 1.769138 893.2 1821.6 Europa 670.9 3.551181 480.0 1560.8 Ganymede 1070.4 7.154553 1481.9 2631.2 Callisto 1882.7 16.689018 1075.9 2410.3
svn add moons.txt
to bring it to Subversion
's noticeFigure 5.3: The Basic Edit/Update Cycle
svn commit
to save his changes in the repositorysvn update
on her working copySubversion
sends her Ron's changesFigure 5.4: RapidSVN
RapidSVN
is a GUI that runs on Windows, Linux, and MacFigure 5.5: TortoiseSVN
TortoiseSVN
is a Windows shell extensionSubversion
) do thismoons.txt
and commits his changes to create version 152Name Orbital Radius Orbital Period Mass Radius Io 421.6 1.769138 893.2 1821.6 Europa 670.9 3.551181 480.0 1560.8 Ganymede 1070.4 7.154553 1481.9 2631.2 Callisto 1882.7 16.689018 1075.9 2410.3 Amalthea 181.4 0.498179 0.075 131 x 73 x 67 Himalia 11460 250.5662 0.095 85 Elara 11740 259.6528 0.008 40
Figure 5.6: Merging Conflicts
moons.txt
Name Orbital Radius Orbital Period Mass Radius (10**3 km) (days) (10**20 kg) (km) Io 421.6 1.769138 893.2 1821.6 Europa 670.9 3.551181 480.0 1560.8 Ganymede 1070.4 7.154553 1481.9 2631.2 Callisto 1882.7 16.689018 1075.9 2410.3 Amalthea 181.4 0.498179 0.075 131 Himalia 11460 250.5662 0.095 85 Elara 11740 259.6528 0.008 40 Pasiphae 23620 743.6 0.003 18 Sinope 23940 758.9 0.0008 14 Lysithea 11720 259.22 0.0008 12
Subversion
tells her there's a conflict
Subversion
puts Hermione's changes and Ron's in moons.txt
Name Orbital Radius Orbital Period Mass Radius (10**3 km) (days) (10**20 kg) (km) Io 421.6 1.769138 893.2 1821.6 Europa 670.9 3.551181 480.0 1560.8 Ganymede 1070.4 7.154553 1481.9 2631.2 Callisto 1882.7 16.689018 1075.9 2410.3 <<<<<<< .mine Amalthea 181.4 0.498179 0.075 131 Himalia 11460 250.5662 0.095 85 Elara 11740 259.6528 0.008 40 Pasiphae 23620 743.6 0.003 18 Sinope 23940 758.9 0.0008 14 Lysithea 11720 259.22 0.0008 12 ======= Amalthea 181.4 0.498179 0.075 131 x 73 x 67 Himalia 11460 250.5662 0.095 85 Elara 11740 259.6528 0.008 40 >>>>>>> .r152
<<<<<<<
shows the start of the section from the first file=======
divides sections>>>>>>>
shows the end of the section from the second file
Subversion
also creates:moons.txt.mine
: contains Hermione's changesmoons.txt.151
: the file before either set of changesmoons.txt.152
: the most recent version of the file in the repositorysvn revert moons.txt
to throw away her changesmoons.txt
moons.txt
to remove the conflict markerssvn resolved moons.txt
to let Subversion
know she's donesvn commit
to commit her changes (creating version 153 of the repository)svn diff
shows him which files he has changed, and what those changes aresvn revert
to discard his workmoons.txt
Figure 5.7: Rolling Back
svn log
shows recent historysvn merge -r 157:156 moons.txt
will do the trick-r
flag specifies the revisions involved/svn/rotor
)cd /svn
svnadmin create rotor
svn checkout file:///svn/rotor
svn checkout http://www.hogwarts.edu/svn/rotor
svn checkout
once, to initialize your working copysvn update
in that directorysvn co http://www.hogwarts.edu/svn/rotor/engine/dynamics
Name | Purpose | Example |
---|---|---|
svn add
|
Add files and/or directories to version control. |
svn add newfile.c newdir
|
svn checkout
|
Get a fresh working copy of a repository. |
svn checkout https://your.host.name/rotor/repo rotorproject
|
svn commit
|
Send changes from working copy to repository (inverse of update ). |
svn commit -m "Comment on the changes"
|
svn delete
|
Delete files and/or directories from version control. |
svn delete oldfile.c
|
svn help
|
Get help (in general, or for a particular command). |
svn help update
|
svn log
|
Show history of recent changes. |
svn log --verbose *.c
|
svn merge
|
Merge two different versions of a file into one. |
svn merge -r 18:16 spin.c
|
svn mkdir
|
Create a new directory and put it under version control. |
svn mkdir newmodule
|
svn rename
|
Rename a file or directory, keeping track of history. |
svn rename temp.txt release_notes.txt
|
svn revert
|
Undo changes to working copy (i.e., resynchronize with repository). |
svn revert spin.h
|
svn status
|
Show the status of files and directories in the working copy. |
svn status
|
svn update
|
Bring changes from repository into working copy (inverse of commit ). |
svn update
|
Table 5.1: Common Subversion Commands |
svn status
compares your working copy with the repository$ svn status
M jupiter/moons.txt
C readme.txt
jupiter/moons.txt
has been modifiedreadme.txt
has conflictssvn update
prints one line for each file or directory it does something to
$ svn update
A saturn/moons.txt
U mars/mars.txt
saturn/moons.txt
has been addedmars/mars.txt
has been updated (i.e., someone else modified it)Exercise 5.1:
course
. You will submit all of your
exercises in this course by checking files into your
repository.Exercise 5.2:
course/ex01/bio.txt
(where
course
is the root of your working copy of your
Subversion repository), and write a short biography of yourself
(100 words or so) of the kind used in academic journals,
conference proceedings, etc. Commit this file to your
repository. Remember to provide a meaningful comment when
committing the file!Exercise 5.3:
mv
and svn
mv
? Put the answer in a file called
course/ex01/mv.txt
and commit your changes.svn
log
in your course
directory. If you didn't know
what you'd just done, would you be able to figure it out from
the log messages? If not, why not?Exercise 5.4:
Blue/ex01/planets.txt
, and add the
following lines:Venus Earth Mars Jupiter Saturn
planets.txt
.)Blue/ex01/planets.txt
so that it reads:
1. Venus 2. Earth 3. Mars 4. Jupiter 5. Saturn
Green/ex01/planets.txt
so that its contents
are as shown below. Do not do svn update
before editing this file, as that will spoil the
exercise.Venus 0 Earth 1 Mars 2 Jupiter 16 (and counting) Saturn 14 (and counting)
svn update
. Subversion
should tell you that there are conflicts in planets.txt
.
Resolve the conflicts so that the file contains:1. Venus 0 2. Earth 1 3. Mars 2 4. Jupiter 16 6. Saturn 14
planets.txt
now has the same content as it has in the
Green repository.Exercise 5.5:
course/ex01/bio.txt
and
commit those changes. Then, use svn merge
to restore
the original contents of your biography
(course/ex01/bio.txt
), and commit the result. When you
are done, bio.txt
should look the way it did at the end
of the first part of the previous exercise.) Note: the purpose
of this exercise is to teach you how to go back in time to get
old versions of files—while it would be simpler in this
case just to edit bio.txt
, you can't (reliably) do that
when you've made larger changes, to multiple files, over a
longer period of time.Exercise 5.6:
svn propset
, and to inspect their
values using svn propget
. Describe three properties
you might want to change on a file or directory, and how you
might use them in your current project.