introduction to subversion - max planck society › subversion.pdf · subversion prints a c during...
TRANSCRIPT
Introduction to Subversion
C. KonzMax-Planck-Institute for Plasma Physics, Garching, Germany
JET, Culham, UKFebruary 2007
”If C gives you enough ropeto hang yourself, think ofSubversion as a sort of ropestorage facility.”Brian W. Fitzpatrick
Why Version Control?
• avoid diverging code development
• improve efficiency of code development
• multiple developers
• keep code history (backward traceability)
• basic documentation through log files
• improve code debugging
• efficient code storage
• server access
Differences to CVS:
• files and directories areversioned
• true version history (add,delete, copy, or rename filesor directories
• atomic commits
• versioned metadata (file anddirectory properties)
• efficient branching andtagging (not proportional toproject size, similar to hard-links)
The Copy-Modify-Merge Solution
The Copy-Modify-Merge Solution
Getting Started
• Create a new repository:
svnadmin create /path/to/repos
• Create your tree of data• Import it into the repository:
svn import /tmp/myproject
http://solps-mdsplus/repos/MYPROJECT/trunk
-m "initial import"
• Check out a working copy:
svn checkout http://solps-mdsplus/repos/MYPROJECT/trunk
myproject
Repository URLs
svn checkout http://solps-mdsplus/repos/MYPROJECT/trunk
Revisions
Each new state of the filesystem tree is a new revision, i.e.,Subversion’s revision numbers apply to entire trees
States of a working file
• unchanged and currentsvn commit no; svn update no
• locally changed and currentsvn commit yes; svn update no
• unchanged and out-of-datesvn commit no; svn update yes
• locally changed and out-of-datesvn commit fails; svn update merge, potential conflict ;followed by svn commit
Basic Work Cycle (I)
• Update your working copy
svn update
• Make changes
svn add foo
svn delete foo
svn copy foo bar
svn move foo bar
Basic Work Cycle (II)
• Examine your changes
svn status foo
svn diff foo
svn revert foo
• Merge other’s changes into your working copy
svn update
svn resolved foo
• Commit your changes
svn commit -m "message"
Examine your changes
svn info
svn log
svn list
svn status
svn diff
Resolve conflicts
Conflicts occur when your local changes cannot be merged with changes to the same fileat the same position in the repository which happened after your last update.
• Subversion prints a C during the update and remembers that the file is in a state ofconflict (no commit possible)
• if file is of a mergeable type, conflict markers are placed into the file to show theoverlapping ares
• three extra unversioned files in your working copy:filename.mine - your working copy before the updatefilename.rOLDREV - BASE revision before the updatefilename.rNEWREV - HEAD revision of the repository
3 possible ways to solve the conflict:
• merge the conflicted text in your working file ”by hand”
• copy one of the temporary files on top of your working file
• run svn revert to throw away all of your local changes
finally run svn resolved foo
Committing
svn commit
svn commit --file logmsg
Branches
A branch is a line of development that exists independently of another line.It always begins life as a copy of something, moves on from there, generating itsown history, and may end with a final merge back into the trunk.
Merging
svn merge -r 343:344 http://solps-mdsplus/repos/PROJECT/trunk my-project-branchsvn merge http://solps-mdsplus/repos/PROJECT/branch1@150http://solps-mdsplus/repos/PROJECT/branch2@212 my-working-copysvn merge -r 100:200 http://solps-mdsplus/repos/PROJECT/trunklast version with current directory as default targetpreview merges with option –dry-run
A word on philosophy
Suggested tree structure:
• /trunk main line for development
• /branches personal projects; alternative versions
• /tags release versions
Users (read only for tags)
Peripheral developers (full read, limited commit)
Core developers (full readand commit, referees)
Four-Eyes-Principle
Using Subversion at JET
• add the following lines to your .subversion/servers file and specify your JETNETuser-id and password:[global]http-proxy-host = webcache.jet.ukhttp-proxy-port = 8080http-proxy-username = <JETNET USER-ID (for proxy server)>http-proxy-password = <JETNET PASSWORD (for proxy server)>
• ensure that this will not be read by anyone else by setting the permissions on it bychmod 600
• create a password (preferably not your JETNET password) and encrypt it by usinghttp://solps-mdsplus.aug.ipp.mpg.de/passwd.htmland send user-id and encrypted password to dpc
• login to jactest-3 and usehttp://solps-mdsplus.aug.ipp.mpg.de for the svn server
WSVN
password required for access to web presentation of the Subversion serverhttp://solps-mdsplus.aug.ipp.mpg.de/wsvn
Wikis
list of code repositories + wikis