introduction to subversion - max planck society › subversion.pdf · subversion prints a c during...

29
Introduction to Subversion C. Konz Max-Planck-Institute for Plasma Physics, Garching, Germany JET, Culham, UK February 2007

Upload: others

Post on 28-Jun-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

Introduction to Subversion

C. KonzMax-Planck-Institute for Plasma Physics, Garching, Germany

JET, Culham, UKFebruary 2007

Page 2: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

”If C gives you enough ropeto hang yourself, think ofSubversion as a sort of ropestorage facility.”Brian W. Fitzpatrick

Page 3: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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

Page 4: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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)

Page 5: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

The Copy-Modify-Merge Solution

Page 6: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

The Copy-Modify-Merge Solution

Page 7: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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

Page 8: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

Repository URLs

svn checkout http://solps-mdsplus/repos/MYPROJECT/trunk

Page 9: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

Revisions

Each new state of the filesystem tree is a new revision, i.e.,Subversion’s revision numbers apply to entire trees

Page 10: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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

Page 11: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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

Page 12: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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"

Page 13: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

Examine your changes

svn info

Page 14: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

svn log

Page 15: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

svn list

Page 16: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

svn status

Page 17: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

svn diff

Page 18: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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

Page 19: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

Committing

svn commit

svn commit --file logmsg

Page 20: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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.

Page 21: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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

Page 22: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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

Page 23: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

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

Page 24: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

WSVN

password required for access to web presentation of the Subversion serverhttp://solps-mdsplus.aug.ipp.mpg.de/wsvn

Page 25: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)
Page 26: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)
Page 27: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)
Page 28: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)

Wikis

list of code repositories + wikis

Page 29: Introduction to Subversion - Max Planck Society › subversion.pdf · Subversion prints a C during the update and remembers that the le is in a state of con ict (no commit possible)