subversion (1)

Upload: mohamed-ali-ferjani

Post on 03-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Subversion (1)

    1/21

    Subversion

    David Turner

    Dec 24, 2007

  • 8/12/2019 Subversion (1)

    2/21

    What is Subversion?

    Subversion is a version control system.

    A version control system allows users to

    manage files, directories, and the changes made

    to them. Subversion can manage any sort of file

    collection (not only source code).

  • 8/12/2019 Subversion (1)

    3/21

    Working copy

    Working copy

    Working copy

    Repository

    Internet

  • 8/12/2019 Subversion (1)

    4/21

    Reasons to Use Subversion

    You can work more easily with other developers

    on software development projects.

    You can undo changes to obtain earlier versions

    of files. Subversion is well known and free.

    Subversion has been under development since

    2000.

  • 8/12/2019 Subversion (1)

    5/21

    CVS versus Subversion

    Subversion fixes problems with CVS.

    (See subversion book for details.)

    Subversion is being adopted as a

    replacement for CVS.

  • 8/12/2019 Subversion (1)

    6/21

    Subversion Architecture

    http://svnbook.red-

    bean.com/en/1.4/images/ch01dia1.png

    http://svnbook.red-bean.com/en/1.4/images/ch01dia1.pnghttp://svnbook.red-bean.com/en/1.4/images/ch01dia1.pnghttp://svnbook.red-bean.com/en/1.4/images/ch01dia1.pnghttp://svnbook.red-bean.com/en/1.4/images/ch01dia1.pnghttp://svnbook.red-bean.com/en/1.4/images/ch01dia1.png
  • 8/12/2019 Subversion (1)

    7/21

    Repository versus Working Copy

    Project code is stored in a server in a data store

    referred to as a repository.

    Developers check out copies of the project

    code into their local environments. Thesecopies are referred to as working copies.

    After making changes to a working copy, the

    developer commits changes to the repository.

    Other developers get these changes by

    updating their working copies.

  • 8/12/2019 Subversion (1)

    8/21

    Differentials

    current

    version

    previous

    version

    previous

    to theprevious

    version

  • 8/12/2019 Subversion (1)

    9/21

    Atomic commits

    A collection of modifications either goes

    into the repository completely, or not at all.

    In other words, a commit will either

    altogether succeed, or it will altogether fail.

  • 8/12/2019 Subversion (1)

    10/21

    Properties

    Each file and directory has a set of

    propertieskeys and their values

    associated with it.

    You can keep certain files from being

    written into the repository by setting the

    svn:ignore property to a string that

    matches the files you want to omit. Suchfiles are said to be unversioned.

  • 8/12/2019 Subversion (1)

    11/21

    Binary versus Character Data

    Subversion expresses file differences

    using a binary differencing algorithm,

    which works identically on both binary and

    character-based files.

    Both types of files are stored in

    compressed format in the repository.

    CVS treats these file types differently.

  • 8/12/2019 Subversion (1)

    12/21

    The Fundamental Problem

    User A gets a copy of file X from the datastore.

    User B gets a copy of file X from the data

    store. User A changes X and writes the new X

    back into the data store.

    User B changes his older version of X andwrites this into the data store, over-writing

    As changes.

  • 8/12/2019 Subversion (1)

    13/21

    Lock-Modify-Unlock

    The lock-modify-unlock solution to thefundamental problem has several problems:

    Two users may want to modify two separate

    parts of the file, which means one user mustwait.

    After locking a file, the user may forget to unlockit.

    Locking does not solve incompatibility problemsbetween separate files. (See subversion bookfor details.)

  • 8/12/2019 Subversion (1)

    14/21

    Copy-Modify-Merge

    Subversion uses a copy-modify-merge approach instead of locking. User A gets a working copy of X.

    User B gets a working copy of X.

    User A changes his working copy of X.

    User B changes her working copy of X.

    A saves his copy of X into the repository. B tries to save his copy of X into the repository, but it fails, because

    her changes were made to a now stale version of X

    B performs an update, which results in As changes to X to bemerged into Bs version of X.

    If As changes do not conflict with Bs changes, the update silently

    completes. If As changes conflict with Bs changes, subversioninserts annotation into X describing the conflicts and then reports theproblem to B. B then manually resolves the conflict.

    Whether B needed to manually resolve conflicts or not, the next stepis for B to commit her changes into the repository, which nowsucceeds.

  • 8/12/2019 Subversion (1)

    15/21

    Copy-Modify-Merge in Practice

    With copy-modify-merge, users do not waiton each other.

    In practice, conflicts are rare and are

    usually straightforward to resolve. Copy-modify-merge does not work well

    with binary files, because changes can not

    be merged. For this reason, subversionprovides a lock-modify-unlock processwhen needed.

  • 8/12/2019 Subversion (1)

    16/21

    Revisions

    Subversion transactions are atomic: they

    either succeed entirely or fail entirely

    After the repository is initially created, it is

    an empty folder and has revision number

    0.

    After committing to a repository with

    revision number n, the repository is

    changed to version n+1.

  • 8/12/2019 Subversion (1)

    17/21

    Revisions

    This diagram and the following text were taken from the online

    version of the Subversion book.

    When Subversion users talk about revision 5 of foo.c,

    they really mean foo.c as it appears in revision 5.

  • 8/12/2019 Subversion (1)

    18/21

    Revisions and Working Copies

    Working copies do not always correspond

    to any single revision of the repository;

    they may contain files from several

    different revisions.

  • 8/12/2019 Subversion (1)

    19/21

    Revisions and Working Copies

    User A checks out repository repo.

    repo/system.h 3repo/system.cpp 3

    User A modifies system.h and commits this file.

    repo/system.h 4repo/system.cpp 3

    User B commits changes to system.cpp, and A updates.

    repo/system.h 5repo/system.cpp 5

  • 8/12/2019 Subversion (1)

    20/21

    States of a Working File

    Unchanged, and current

    Locally changed, and current

    Unchanged, and out-of-date Locally changed, and out-of-date

  • 8/12/2019 Subversion (1)

    21/21

    Update and Commit

    update commit

    Unchanged, and

    current

    does nothing does nothing

    Locally changed,

    and current

    does nothing writes changes

    into repo

    Unchanged, and

    out-of-date

    replaces working

    file with new one

    does nothing

    Locally changed,

    and out-of-date

    merges changes

    into working file

    operation fails

    with out-of-date

    error