SUBVERSION a.k.a SVN Earliest tools for version Under Linuxcontrol 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...
SUBVERSION a.k.a SVN I will present the Under Linux“command line” version. By O. TeytaudNo window, no mouse.You can find graphicalinterfaces as well; e.g. TortoiseSVN.
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.
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.
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.
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 specificmore complicated cases (many distinct versions). I recommend SVN as a first choice.
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 specificmore complicated cases (many distinct versions). I recommend SVN as a first choice.Also termed “source code management” systems.
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.
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/johnsvnadmin create svn This is the svn root. Run by one user only ==> dont 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/projectJPICHe can create a “brother” directory for works with André and Olivier:svn mkdir file:///home/john/svn/projectJAOand so on – no problem.
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.
Step 4: putting the current files (if any) in the repositoryForget this step if you have no files for the moment.cd /home/john/work/projectJPIC ### assuming that the project ### is in /home/john/work/projectJPICsvn import file:///home/john/svn/projectJPIC ==> ok, the files are installed!
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 directoryin 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.
Step 6: understanding ! Johns Paulsworking copy. working copy. Pauls SVN repository Never modify Pauls SVN repository directly ! I-Chens SVN would become working copy. crazy.
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
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 its not up-to-date ==> always “svn update” before “svn commit”.
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.
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.
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.
Step 11b: conflictsSuch 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.
Step 11c: conflicts ==> edit the file. <<<<<<< .mine x=x+1; ======= ++x; >>>>>>> .r6 ==> write what you really want, and remove “<<<”, “===”,”>>>”==> svn resolved taiwan.cpp
Step 12: many others! svn revert ==> removes your modificationssvn diff ==> checks differences between versions. svn rm ==> removes a file
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”.
Summary:- All big projects now under version management systems.- The administration of a SVN can be a bit tricky, but as a user its 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.
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 readme4) Collect the following info: svn info svn log svn status svn blame readme
Decentralized versions ? SVN style GIT style: you get the patchesWC1 WC2 you want from who you want SVN repository WC1 WC2 WC3More possibilities with Git; WC3 but far less convenient
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 CodeGit SourceForge GNU Savannah SourceForge Google Code Bitbucket Thanks Wikipedia for providing a list of free websites.
Multimedia Browser Java IDE Java DK playerMercurial users: Mozilla, NetBeans, Xine, Xen, OpenJDK,OpenOffice.org, OpenSolaris, wmii, MoinMoin, Linux-HA, Python==> many sources consider Mercurial as better than git (samesyntax, 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.
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.