2. SUBVERSION
a.k.a SVN
Earliest tools for version Under Linux
control systems: the mid-70s.
By O. Teytaud
Stable tool: 1986, CVS.
Now: SVN widely used for
source code or text files.
Recent tools: git, mercurial...
3. SUBVERSION
a.k.a SVN
I will present the Under Linux
“command line” version.
By O. Teytaud
No window, no mouse.
You can find graphical
interfaces as well; e.g.
TortoiseSVN.
4. Various reasons for which
I use command line
I know most of you (almost) never use
the command line.
I use command line all the day long.
Reason 1: I am an old guy.
When I learnt computer science, there was no window on a computer,
no mouse, and everything was done through command line.
Reason 2: I work on High-Performance Computing.
Many things on clusters are done without any window.
Reason 3: For many things, you would be indeed faster if you
were working in command line. Give it a try :-)
In particular, for administration.
5. Why version control systems ?
Meeting 1: 3 persons A, B, C, decide
to work together on a project:
- A creates france.h and france.cpp;
- B creates taiwan.h and taiwan.cpp;
- C creates US.h and US.cpp.
Meeting 2: They put all files in the same directory.
It works.
Then all keep a copy of France + Taiwan + US;
then, each of them modifies some files.
A modifies france.cpp, and a little bit US.cpp.
B modifies taiwan.cpp, and a little bit US.cpp.
C modifies US.cpp.
Meeting 3: They (try to) put all files in the same directory.
Which US.cpp should they use ?
==> nothing works. They spend hours debugging.
6. Version control systems
is here for that !
Meeting 1: 3 persons A, B, C, decide
to work together on a project:
- A creates france.h and france.cpp;
- B creates taiwan.h and taiwan.cpp;
- C creates US.h and US.cpp.
Meeting 2: They put all files in the same SVN-repository.
It works.
Each of them modifies some files.
A modifies france.cpp, and a little bit US.cpp.
B modifies taiwan.cpp, and a little bit US.cpp.
C modifies US.cpp. THEY ALL SEE MODIFICATIONS BY OTHERS !
Meeting 3: They are very happy!
Everything works.
7. Nowadays, no big
Programming project
without
version control systems (VCS).
CVS = good old system for VCS.
SVN = CVS + some improvements.
(tortoiseSVN for Windows)
GIT, MERCURIAL = for some specific
more complicated cases (many distinct
versions).
I recommend SVN as a first choice.
8. Nowadays, no big project in
computer science without
version control systems (VCS).
CVS = good old system for VCS.
SVN = CVS + some improvements.
GIT, MERCURIAL = for some specific
more complicated cases (many distinct
versions).
I recommend SVN as a first choice.
Also termed “source code management” systems.
9. Step 1: install SUBVERSION on your system.
No problem:
Ubuntu Linux: sudo apt-get install subversion.
Windows: use google, find subversion
for Windows, download/install it.
At many points when you use it,
SVN will ask for a log message.
You just have, then, to explain what you are doing;
this will be visible by other users.
10. Step 2: choosing where is the repository
Here, John is the admin of the SVN repository.
e.g. John will create the repository in his own directory.
cd /home/john
svnadmin create svn
This is the svn root.
Run by one user only ==> don't have one SVNROOT per user.
John will work with Paul and I-Chen. He creates a directory for this:
svn mkdir file:///home/john/svn/projectJPIC
He can create a “brother” directory for works with André and Olivier:
svn mkdir file:///home/john/svn/projectJAO
and so on – no problem.
11. Step 3: Take time for understanding :-)
John has his repository ready on his machine.
But Paul and I-Chen do not work
on the same machine.
So what ?
We will have to communicate through internet.
The idea is to make the process automatic.
12. Step 4: putting the current files
(if any) in the repository
Forget this step if you have no files for the moment.
cd /home/john/work/projectJPIC
### assuming that the project
### is in /home/john/work/projectJPIC
svn import file:///home/john/svn/projectJPIC
==> ok, the files are installed!
13. Step 5: create working copies!
You should never work in
/home/john/svn/projectJPIC
This is for SVN only.
You should work on working copies.
This is true for Paul, I-Chen, and also for John!
Paul, I-Chen and John all go to the directory
in which they want to work, and do:
svn checkout file:///home/john/svn/projectJPIC
==> this creates a working copy.
==> you can modify it as much as you want.
14. Step 6: understanding !
John's
Paul's
working copy. working copy.
Paul's SVN
repository
Never modify Paul's
SVN repository
directly !
I-Chen's SVN would become
working copy. crazy.
15. Step 7: sending your modifications.
I edit France.cpp.
I like my changes, I want to
make them available
for B and C.
When you want to send your version to the
SVN repository:
svn commit France.cpp
or just
svn commit
(will send all your modifications, not just France.cpp)
Or:
svn commit -m “major bugfix in France.cpp”
to choose the message
16. Step 8: receiving others' modifications
svn update taiwan.cpp
==> will just update Taiwan.cpp
svn update
==> will update everything.
SVN will not accept to commit a file
if it's not up-to-date
==> always “svn update” before
“svn commit”.
17. Step 9: adding new files
svn add belgium.cpp
==> I tell SVN that the new file
“Belgium.cpp” is now under
Version control
svn commit belgium.cpp
==> will send belgium.cpp to others.
18. Step 10: get information!
svn info
==> will tell you various global info.
svn log france.cpp
==> will tell you what
happened to france.cpp
svn blame france.cpp
==> will tell you, for each line,
where it comes from.
19. Step 11a: conflicts
If I modify line 10,
from “x++;” to “++x;”
whereas you write:
from “x++;” to x=x+1;”.
then SVN will have a trouble.
20. Step 11b: conflicts
Such a trouble is termed a conflict:
svn update taiwan.cpp
replies “C taiwan.cpp”
which means “There is a conflict
in taiwan.cpp, please solve.”
==> edit the file.
21. Step 11c: conflicts
==> edit the file.
<<<<<<< .mine
x=x+1;
=======
++x;
>>>>>>> .r6
==> write what you really want,
and remove “<<<”, “===”,”>>>”
==> svn resolved taiwan.cpp
22. Step 12: many others!
svn revert ==> removes your modifications
svn diff ==> checks differences between versions.
svn rm ==> removes a file
23. Step 13: without shared disk space ?
We have used “file:///”
which means that you have access to a shared
disk (Paul, I-Chen and John write/read the
same disk).
This is not necessarily the case.
Then replace “file:///”
by “svn+ssh://”
and install “svnserve”.
24. Summary:
- All big projects now under version
management systems.
- The administration of a SVN can be a bit tricky,
but as a user it's quite easy; in everyday life, you
will use essentially:
- svn update
- svn commit
- ...and sometimes (unfortunately) svn resolved
- When no common disk space, you need “ssh”; a bit
more tricky, as an admin, but not that much.
25. Home work:
1) Make groups (~3/4 persons, A B C and D).
2) Install the SVN together; set it up with
- one file “readme”
- one directory “plane”
3) A, B, C and D all put one image in the “plane”
Directory, described in the readme
4) Collect the following info:
svn info
svn log
svn status
svn blame readme
26. Decentralized versions ?
SVN style GIT style:
you get the patches
WC1 WC2 you want from who
you want
SVN
repository WC1 WC2
WC3
More possibilities with Git; WC3
but far less convenient
27. I hate administration.
How can I use “git” or “svn” or cvs” ?
Alioth
BerliOS
Assembla
GitHub
BerliOS
Gitorious
Betavine
Svn
JavaForge (with pull requests to control
source code contribution) Freepository
Google Code
Git SourceForge
GNU Savannah SourceForge
Google Code
Bitbucket Thanks Wikipedia for
providing a
list of free websites.
28. Multimedia
Browser Java IDE Java DK
player
Mercurial users: Mozilla, NetBeans, Xine, Xen, OpenJDK,
OpenOffice.org, OpenSolaris, wmii, MoinMoin, Linux-HA, Python
==> many sources consider Mercurial as better than git (same
syntax, better doc)
SVN users: ASF, SourceForge, FreeBSD, Google Code, KDE, GCC,
Ruby, Mono, PuTTY, Zope, Xiph, GnuPG, CUPS, Wireshark, TWiki,
Django, available on CodePlex, and many organizations worldwide
(for simple standard use, SVN is probably the best choice)
Git users: Linux kernel, GNOME, Perl 5, X.Org, Cairo,
Qt Development Frameworks, Samba, OpenEmbedded,
Ruby on Rails, Wine, Fluxbox, Openbox, Compiz Fusion,
XCB, ELinks, XMMS2, e2fsprogs, GNU Core Utilities,
DokuWiki (plenty of “geek-style” GNU/Linux stuff)
==> becomes a standard... but more tricky than SVN.