Presentation is loading. Please wait.

Presentation is loading. Please wait.

Subversion.

Similar presentations


Presentation on theme: "Subversion."— Presentation transcript:

1 Subversion

2 Subversion: What To Do? Problems of code management in a project
The life of the project can be lengthy: need to manage the development history Change of architecture Change of people involved in the development Working in parallel on several versions Maintenance of an old version in parallel with the current version Test of new functionality without an impact to the current version Being able to easily spread change from one version to another Several people involved at the same time in development Working simultaneously on the same code Detect and help to resolve conflicts Family member of Version Control System (VCS) CVS is 1 of the oldest and best known (open source) Subversion (SVN) covers the main concepts while modernising Text and binary, language neutral, not configuration management

3 The model CVS/SVN repository Working area Working area A B
check-out check-out Local copies in working area No "locking": several users may modify different copies of the same file Central repository Database containing all versions (revisions) unique to a single project commit (check-in) Working area B Working area A Synchronisation between the working area and the repository Detection/Resolution of conflicts

4 SVN: Reference a Repository
We specify a repository by its URL Example: https: / / svn.lal.in2p3.fr/projects/Etudiants We call a branch any directory in the repository Matches a directory in the workspace An additional level in the URL Examples: https: / / svn.lal.in2p3.fr/projects/Etudiants/ipn5 https: / / svn.lal.in2p3.fr/projects/Etudiants/ipn5/HelloWorld Wide range of SVN customers Command line: svn Command names generally identical to CVS Web Client: WebSVN Only views the repository

5 Major Operations checkout update revert info status resolved log add
WA R WA WA R checkout update revert info status resolved log add commit

6 Check-out Creates a local copy (a branch) repository svn co URL
Ex : svn co Projects R WA % svn co Projects Checked out revision 4. % cd Projets/

7 Info Lets you know the branch associated with the local directory
svn info WA % svn info Path: . URL: Repository UUID: 589c a-0410-a932-a3fdf8820ca6 Revision: 4 Node Kind: directory Schedule: normal Last Changed Author: jouvin Last Changed Rev: 4 Last Changed Date: :07: (Tue, 17 Jan 2006)

8 Add Adds file(s) to the repository at the next synchronization
svn add file / directory Necessary for any file/directory created after the check-out If directory is selected, treats all contained files and directories R WA % echo "Test" > file1.txt % svn add file1.txt A file1.txt

9 Status Lets you know the status of the working directory
svn status [-u] 1 line per file modified with respect to the repository -u forces verification compared to the repository and not the local copy WA % svn status A file1.txt

10 Commit Writes local changes to the repository svn ci -m "message"
Creates a new revision of the repository containing all the changes Requests a username/password if necessary (ens2006, non-modifiable) Possible only if the workspace is up to date as compared to the repository R WA % svn ci -m 'Ajout de file1.txt' Adding file1.txt Authentication realm: < LAL … Password for 'jouvin': Transmitting file data . Committed revision 5.

11 Update Imports changes from the repository to the local copy
svn update [-r revision] Adds new files (A) or updates others (U) Preserves local changes by doing a merge (G) Indicates conflict: local modification in conflict with a change in the repository (C) In case of conflict, creates several versions of file locally Prevents commits R WA % echo “Personal change” >> file1.txt % svn update C file1.txt  conflit in the file A file2.txt  added file Updated to revision 7. % ls file1.txt file1.txt.r5 file2.txt file1.txt.mine file1.txt.r7

12 Resolved Indicates that the conflict was resolved svn resolved file
Deletes versions created temporarily WA % cp file1.txt.mine file1.txt % svn resolved file1.txt file1.txt file1.txt.mine file1.txt.r5 file1.txt.r7 Resolved conflicted state of 'file1.txt' % ls file1.txt file2.txt

13 Revert Returns to the version of the repository
svn revert file/directory Restores version of the last update. The local changes are lost R WA % cat file1.txt Test Modif perso % svn revert file1.txt Reverted 'file1.txt' 1st modif

14 Log Lists messages associated with each revision of a file/directory
svn log [file/directory] [-v] [--stop-on-copy] Lists only revisions applied to the current branch (file) Includes copy operations between branches, unless --stop-on-copy R asc/jouvin % svn log r7 | jouvin | :53: (Wed, 18 Jan 2006) | 1 line Modif 1st file r6 | jouvin | :51: (Wed, 18 Jan 2006) | 1 line Add 2nd file r5 | jouvin | :49: (Tue, 17 Jan 2006) | 1 line Add file1.txt ……

15 Summary of Major Operations ...
check-out : creates a local copy (a branch) repository svn co URL Ex : svn co Projects info : lets you know the branch associated with the local directory svn info add : adds file(s) to the repository at the next synchronization svn add file / directory Necessary for any file/directory created after the check-out If directory is selected, treats all contained files and directories status : lets you know the status of the working directory svn status [-u] 1 line per file modified with respect to the repository -u forces verification compared to the repository and not the local copy R WA WA R WA WA

16 ... Summary of Major Operations…
commit : writes local changes in the repository svn ci -m "message" Creates a new revision of the repository containing all the changes Requests a username/password if necessary (ens2006, non-modifiable) Possible only if the workspace is up to date as compared to the repository update : imports changes from the repository in the local copy svn update [-r revision] Adds new files (A) or updates others (U) Preserves local changes by doing a merge (G) Indicates conflict: local modification in conflict with a change in the repository (C) In case of conflict, creates several versions of file locally Prevents commits resolved : indicates that the conflict was resolved svn resolved file Deletes versions created temporarily R WA R WA WA

17 … Summary of Major Operations
revert : returns to the version of the repository svn revert file/directory Restores version of the last update. The local changes are lost log : lists messages associated with each revision of a file/directory svn log [file/directory] [-v] [--stop-on-copy] Lists only revisions applied to the current branch (file) Includes copy operations between branches, unless --stop-on-copy R WA R

18 Operations on Files ... SVN keeps a track of all files renamed, copied, destroyed… Helps to maintain the history even if the file is renamed Reports the revision of the file which resulted in a new file (copy /mv) Manages the creation/deletion/rename of directories No implicit transactions on files Must notify the changes to SVN svn status indicates inconsistencies (!) To simplify, SVN allows to invoke the cp, mv, mkdir… svn cp, mv svn, svn rm, svn mkdir Make SVN forget about a deleted file svn rm --force file

19 ... Operations on Files % svn cp file1.txt file3.txt A file3.txt % ls
file1.txt file2.txt file3.txt % svn status A + file3.txt

20 Advanced Features diff: shows the differences between 2 versions of a file or group of files With the work space: svn diff [-r revision] file/directory Between 2 revisions to the repository: svn diff [-r r1:r2] file/directory Easier with a Web interface (WebSVN, Trac…) WebSVN the LAL: merge: reverts to an earlier revision of the repository svn merge -r HEAD:revision file/directory Does not change the repository but only the local copy (you have to commit to validate a return to the previous revision) update helps to restore an earlier version in the work area but will cause a conflict when committed commit requires that the workspace is up to date with the last revision R WA

21 To Learn More… Documentation SVN online
The online help svn help [command]


Download ppt "Subversion."

Similar presentations


Ads by Google