26
CHARLES UNIVERSITY IN PRAGUE http://d3s.mff.cuni.cz faculty of mathematics and physics Version Control ( Správa verzí ) Pavel Parízek [email protected]

Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

CHARLES UNIVERSITY IN PRAGUE

http://d3s.mff.cuni.cz

faculty of mathematics and physics

Version Control(Správa verzí)

Pavel Parí[email protected]

Page 2: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

What is it good for ?

Nástroje pro vývoj software Version Control 2

Keeping history of system evolution

Tracking progress

Allowing concurrent work on the system

Teams of developers

Possible conflicts

Easy reverting to a previous version

Safer experimentation

Page 3: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Typical architecture

Nástroje pro vývoj software Version Control 3

Source code repository(versioned sources)

Working copy

synchronization

Working copy

Page 4: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Basic usage scenario

Nástroje pro vývoj software Version Control 4

Source coderepository

Working copy

check-out or update1.

2. modify & test

3.add & check-in

Page 5: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Categories of versioning systems

Nástroje pro vývoj software Version Control 5

Centralized

CVS: Concurrent Versioning System

The “classic” system

SVN: Subversion

Currently still used by many open-source projectshttp://apache.org/index.html#projects-list

Distributed

Git, Mercurial, Bazaar

Page 6: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Branches and merging

Nástroje pro vývoj software Version Control 6

main line of development (master branch)

concurrent development (experimenting)

branching merging

time & software versions

bug fix in released version

branching

NOW

Page 7: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Conflicts

Nástroje pro vývoj software Version Control 7

Options

Postpone resolving

Choose version

External merge tool

and many others

Conflict markers

<<<<<<< and >>>>>>> in source file

Three variants of the source file created

Page 8: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Tree conflicts

Nástroje pro vývoj software Version Control 8

Typical cause

Renamed files and directories

Deleted files

Solution

Make proper changes in the working copy

Use patches created with the diff command

Commit when everything is in a clean state

Page 9: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Tags

Nástroje pro vývoj software Version Control 9

Snapshot with a human-friendly name

Logical copy of the whole source tree

Page 10: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Best practices: synchronizing developers

Nástroje pro vývoj software Version Control 10

Software developed in large teamsPeople may not be always able to coordinate efficiently

Solution: Copy-Modify-MergeConcurrent modification of source filesResolving conflicts when they happen

Alternative: Lock-Modify-UnlockThe old classic approach (“before internet”)Does not scale well (exclusive access)Not very robust (people forget to unlock)

Page 11: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Best practices: branches and merging

Nástroje pro vývoj software Version Control 11

Use branches for experimental features

Create special branch for each feature

Separate release and development branches

Propagating bugfixes from development to stable

Merge often and synchronize with trunk

Lower chance of ugly conflicts occurring

Smaller conflicts are easier to resolve

Commit often others will have to merge

Page 12: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Subversion

Nástroje pro vývoj software Version Control 12

Page 13: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Important features

Nástroje pro vývoj software Version Control 13

Whole source tree versioned

Integer numbers (1,2,3,...)

Mixed versions in the working copy

Atomic commits

Versioning for files and directories

Operations: move, rename, delete

Support for binary files

Disconnected operations

Metadata in “.svn” directories

Page 14: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Locations

Nástroje pro vývoj software Version Control 14

Repository

Remote server (svn+ssh://<network url>)

Local directory (file://<absolute path>)

Working copy

Local directory on your computer

Page 15: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Basic commands

Nástroje pro vývoj software Version Control 15

Help: svn help <command>

Create new repository: svnadmin create

Create new working copy: svn checkout

Update working copy: svn update

List modified and new files: svn status -v

Show differences between repository and working copy (two versions): svn diff –r<version>

Use svn diff -r<v1>:<v2> to see differences between two specific versions

Add new files into repository: svn add

Commit changes: svn commit –m “...”

Display information about file: svn info

Page 16: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Few more useful commands

Nástroje pro vývoj software Version Control 16

Undo changes in working copy: svn revert

See full history of a given file: svn log

Importing whole unversioned tree into repository: svn import <dir> <repo>

Exporting content of the repository without metadata: svn export

Page 17: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Managing files and directories

Nástroje pro vývoj software Version Control 17

Commandssvn add <path>

svn delete <path>

svn copy <path1> <path2>

svn move <path1> <path2>

svn mkdir <path>

PathIn your local working copy

Repository (auto-commit)

Page 18: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Branching and merging – commands

Nástroje pro vývoj software Version Control 18

Create new branchsvn copy <main line repo path> <branch repo path>

Print differencessvn diff <main line repo path> <branch repo path>

Make your branch up-to-date (sync merge)svn merge <main line repo path>

svn merge ^/<main line repo dir>

Merge branch into the main line (trunk)svn merge --reintegrate ^/<branch repo dir>

Previewsvn merge <repo path> --dry-run

Page 19: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Undoing committed modifications

Nástroje pro vývoj software Version Control 19

Merge negative version range into local working copysvn merge <repo path> -r <v1>:<v2>

Note: v1 > v2

Commit everything

Page 20: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Cherrypicking

Nástroje pro vývoj software Version Control 20

Merge specific change into your branchsvn merge -c <version> <repo path>

Commit your branch

Page 21: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Standard repository layout

Nástroje pro vývoj software Version Control 21

/trunk/branches/tags

/project1/trunk/project1/branches/feature1/project1/tags/project2/trunk/project2/branches/project2/tags/R_1_0/project2/tags/R_1_2_1

Page 22: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Revision keywords

Nástroje pro vývoj software Version Control 22

HEADLatest version in the repository

BASERevision number in the working copy (before modifications)

COMMITTEDThe latest revision in which the item changed and was committed (not larger than BASE)

PREVEqual to COMMITTED-1

Page 23: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Properties

Nástroje pro vývoj software Version Control 23

Standard name-value pairsMany internal system properties

svn:ignore, svn:eol-style, ...

Setting property valuesvn propset <name> <value> <path>

svn propset <name> -F <file> <path>

Other commandssvn proplist

svn propget

svn propedit

Page 24: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Locks

Nástroje pro vývoj software Version Control 24

Still needed to work with binary files

Merge not supported for concurrent modifications

Lockingsvn lock

Unlockingsvn commit

svn unlock

Inspectingsvn info

Page 25: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

GUI clients for SVN

Nástroje pro vývoj software Version Control 25

Tortoise SVN (Windows)

http://www.tortoisesvn.net

Eclipse IDE

Other

kdesvn (Linux)

svnx (Mac OS)

Page 26: Version Control - Univerzita Karlova...svn proplist svn propget svn propedit Locks Nástroje pro vývoj software Version Control 24 Still needed to work with binary files Merge not

Links

Nástroje pro vývoj software Version Control 26

http://subversion.apache.org

SVN Book

http://svnbook.red-bean.com